GitHub Add SSH
GitHub Add SSH: Linking Your SSH Public Key to GitHub
Adding your public SSH key to your GitHub account authorizes your machine to clone, pull, and push private or public repositories over git@github.com URLs. Once linked, Git recognizes your laptop immediately without prompting for tokens.
Copying Your Public Key Safely
Print your .pub key in the terminal or copy it directly to your clipboard so no extra spaces or line breaks slip in:
cat ~/.ssh/id_ed25519.pub
On macOS you can pipe straight to the clipboard with pbcopy < ~/.ssh/id_ed25519.pub, and on Windows Git Bash you can run clip < ~/.ssh/id_ed25519.pub. Make sure the copied string starts with ssh-ed25519 and ends with your email comment.
Adding the Key in GitHub Settings
Open GitHub in your browser and follow these steps:
- Click your profile avatar in the top-right corner and open Settings.
- In the left sidebar, select SSH and GPG keys.
- Click New SSH key.
- Enter a recognizable Title such as
Work Laptop UbuntuorPersonal MacBook. - Keep Key type set to Authentication Key, paste your
.pubcontents into Key, and click Add SSH key.
Verifying Your SSH Connection
Test the connection from your terminal before pushing code:
ssh -T git@github.com
On the very first connection, SSH prints GitHub's host key fingerprint and asks Are you sure you want to continue connecting (yes/no)?. Type yes and press Enter. When setup succeeds, GitHub replies: Hi your-username! You've successfully authenticated, but GitHub does not provide shell access.
Troubleshooting Permission Denied Errors
If ssh -T git@github.com returns Permission denied (publickey), inspect which keys SSH is offering with verbose output:
ssh -vT git@github.com
Confirm your key is loaded (ssh-add -l) and check that your repository remote actually uses an SSH URL (git@github.com:user/repo.git) rather than https://.
Frequently Asked Questions
Why does ssh -T git@github.com say GitHub does not provide shell access?
That message means authentication succeeded. GitHub disables interactive SSH terminal logins for security and only permits Git transport commands over that connection.
Can I add the same SSH key for commit signing too?
Yes. On the New SSH key screen, you can add the same .pub key a second time with Key type set to Signing Key to display Verified badges on SSH-signed commits.
How do I switch an existing HTTPS repository to SSH?
Run git remote set-url origin git@github.com:your-username/starter-site.git inside the project folder.
Unlock Your
Full Potential.
Sign in to track your learning journey, earn industry-recognized certificates, and join our elite developer community.
Quick Access With