Sharing your GitHub SSH public key

Public, Git

harrylevine

Created: Oct 15, 2015     Updated: Oct 16, 2015


Check if you have an SSH key by calling $ ls -al ~/.ssh. If you have these in there:

Then continue on. If not, follow the steps in the link at the bottom of the page.

1 - In your terminal, go to the root directory
2 - enter $ ssh-keygen -t rsa
3 - click enter through all questions that arise to accept the defaults

It will end up producing a id_rsa.pub file that is probably located ~/.ssh/id_rsa.pub, or very close to there.

The key that is in this id_rsa.pub file is safe to share publicly. Simply share the file as you normally would.

I did the above in order to gain privileges to be able to deploy a particular branch to a deployment/staging box. After I gave the file to the network engineer, the deployment still wouldn't work.

The error message was basically saying that my SSH key was not attached to the GitHub repository in question. In order to fix that:

1 - I went to my github.com/settings/ssh page in GitHub
2 - Clicked the Add SSH Key button
3 - Gave it a relevant name
4 - Copy and pasted in the key from my id_rsa.pub file
5 - Saved it

That worked!

Here's more info on the topic: https://help.github.com/articles/generating-ssh-keys/