Using SSH With GitHub

SSH is really the way to go when it comes to pushing your changes to GitHub but every now and then, I need to set it up but forget what I did in the past. Gosh I hate that :-) Searching the GitHub help can also lead you in circles so this is a short post using external sources to show you what you need to do. For this, I will assume you have no keys set up but that you might have already cloned your repository on your local machine. I’m also using Linux but Mac is similar and Windows versions can be found.

Set Up Your SSH Key

Here’s where we start. You need this to prove you are who you say you are and some pretty easy steps can be found here. Make sure you use the same email address which you commit changes with on GitHub.

Adding Your SSH Key To GitHub

Now you need to tell GitHub what your brand new key is. There’s a video here for the visual amongst us but otherwise, start from the second section. All being well, you should get an email shortly afterwards saying that the key was added.

Changing Your Remote Repository To Use SSH

If you did something like this when you first created your repository:

$ git clone http://..............

then your remote repository isn’t set for using SSH. Follow these steps in that case. Oh, you can’t remember that either? Easily done in my case. Just take a look at your origin repository with this command:

$ git remote -v
origin (fetch)
origin (push)

Can you see the git@ part? That means it is using SSH (the output is what I had once I made my change). If it had it “https” then…you guessed it…it’s the opposite. You should be all set to go now. Make a change, commit and then push it using your secret password (the SSH one). Hopefully, you should find the commit happens as expected.

Hi! Did you find this useful or interesting? I have an email list coming soon, but in the meantime, if you ready anything you fancy chatting about, I would love to hear from you. You can contact me here or at stephen ‘at’