How to add SSH key to Github
This should have been easy, it wasn’t. Here is how I fixed it.
This post is for the Googles, trying to help some poor soul who is stuck where I was trying to add an SSH key to Github. I figured it out, and so to guide those who come after, and not repeat the mistake of DenverCoder9…
Here is what worked for me. GitHub gives you 3 articles. 1 and 3 worked great. I ran into two problems on 2.
- Checked for existing SSH keys ✅ — Githubs article worked well here. No issues.
- Generated a new SSH key and added it to the ssh-agent — 🚩 — ran into issues here. One command wouldn’t work, one I didn’t know how to do.
- Adding a the SSH key to your GitHub account
Problems with adding ssh key to ssh-agent
Issue 1. Command wouldn’t work
The Github article had commands that just wouldn’t work for me.
$ eval "$(ssh-agent -s)"
Wouldn’t work. Gave an error ‘command not found’
Did some googling, found an alternative on Stackoverflow
Could not open a connection to your authentication agent
I am running into this error of: $ git push heroku master Warning: Permanently added the RSA host key for IP address…
eval `ssh-agent -s`
Finally worked for me. I have no idea what one worked and the other didn’t. Could have been user error. But I made it past that obstacle.
Issue 2. How to modify ssh/config?
The article then casually mentioned “you will need to modify your
~/.ssh/configfile to automatically load keys into the ssh-agent and store passphrases in your keychain.”
Yeah I had no idea how to do that. So again to Google. Found this article.
Setup an SSH Config File
If you use SSH even somewhat often, it would benefit you to setup a basic SSH config file. If you're curious why, would…
This command did the trick.
Conclusion — You can do it
So if you get stuck on step 2 of adding your ssh key to Github, here is an olive branch of what worked for me. Good luck traveler.