Put an SSH key in GitHub

You'll need to put an SSH key from your computer on to your GitHub account in order to work with GitHub.

Step One: Create Your Key

If you run the following command, it will create a key on your computer. If you think you already have a key, you can run ls -al ~/.ssh to see if it's there - if it is, skip to the copying step.

ssh-keygen -t rsa -b 4096 -C "your_email@example.com"

Click enter to accept the defaults. If you choose to use a passphrase, keep it short! You should see a statement about your public information and key being saved.

Step Two: Copy your key

The next step is to copy this information so you can paste it into your GitHub account settings. Because of the nature of the key, you'll probably want to use a special command to copy the key (as opposed to opening up the document in a text editor and copying it from there).

Copying on a Mac

pbcopy < ~/.ssh/id_rsa.pub

Copying on a PC

clip < ~/.ssh/id_rsa.pub

If "clip" doesn't work on your PC, try:

cat ~/.ssh/id_rsa.pub

Essentially, you want the text of this file in your computer's clipboard. If none of the commands above are working, try to open the file with a text editor and select all the characters.

Step Three: Paste your key into your GitHub account settings

The last step in authenticating with GitHub is to log in to GitHub, go to your settings page (to do this, click on your profile picture and select "Settings from the drop down menu"). Once you're on the settings page, click "SSH Keys" on the left-hand menu, then "Add SSH key".

Is this step not working well for you? You can try another way to authenticate: See GitHub instructions for authenticating through https and a credential tool.