Setting up SSH keys for GitHub Access




Why SSH Keys for Git Hub

SSH keys provide a secure connection to Git Hub without the need to enter your username and password every time you want to connect and download code from Git Hub repository.

The vast majority of users may use HTTPS URLS to clone repositories, for instance https://github.com/threenine/orion.git, . However, there is an alternate approach which makes use of SSH URLS git@github.com:threenine/StopWebCrawlers.git.

In this post I will provide instructions on how to generate SSH keys for Git Hub on OSX and Linux machines.  If you’re on a Linux machine you may want to check out this handy little tutorial on how to use pbcopy on ubuntu.

Generate SSH keys

To generate SSH you will need to open a Terminal Window and navigate to your SSH key directory  and check for any existing keys

If you get a No such file or Directory error changing into the directory, chances are the directory doesn’t exist. We will therefore need to create it.

If the folder previously existed just check to see what files existed

create_folder




If you see some names similar to id_rsa,  we could delete them or back them up into a separate folder.

Now we can generate a new SSH key pair using the ssh-keygen command.  We will be using your email address.

Answer the additional questions.  Personally I think it is better to keep the default name of id_rsa .

generate_key

Once we have completed the key generation, we need to copy the content of the id_rsa.pub to your clipboard .  We will use pbcopy to do this. If you’re on a Linux machine you may want to check out this handy little tutorial on how to use pbcopy on ubuntu.

Adding your key to GitHub

Login into your GitHub.com account, go to your Account Settings and add the new SSH key.  Assign a name, such as the name of your computer, and paste the value of your public key.



Once you’ve completed the above step, you can now test the SSH connection to GitHub, by executing the following command in your terminal.

If you see a response similar too :

github_access

Then everything is set up.

The first time you connect to GitHub , you may recieve an Authenticity of Host …. Can’t be established.  Don’t panic, just proceed by answering Yes and continue.

Gary Woodfine

Freelance Full Stack Developer at threenine.co.uk
Helps businesses by improving their technical proficiencies and eliminating waste from the software development pipelines.

A unique background as business owner, marketing, software development and business development ensures that he can offer the optimum business consultancy services across a wide spectrum of business challenges.
π