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…

Image for post
Image for post
there is an xkcd for everything

Here is what worked for me. GitHub gives you 3 articles. 1 and 3 worked great. I ran into two problems on 2.

  1. Checked for existing SSH keys ✅ — Githubs article worked well here. No issues.
  2. 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.
  3. 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

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.

This command did the trick.

nano ~/.ssh/config

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.

Written by

Code, design, cook. Make stuff. Cookies. @BYU grad.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store