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, . However, there is an alternate approach which makes use of SSH URLS

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


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 .


Once we have completed the key generation, we need to copy the content of the 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 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 :


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
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.

Affiliate Disclaimer

Disclosure: Please note that some of the links included in the blog posts are affiliate links, which means I will earn a commission if you decide to make a purchase.

I only include affiliate links to products, services and companies that I have personal experience and have actually used. I only recommend them because they are helpful and useful, not because of the small commissions I make if you decide to buy something.

Please do not spend any money on these products unless you feel they are relevant, suitable and will help you achieve your goals.

Buying anyone of these products and the commisions earned will not make me an overnite multi millionaire, but they will help to cover the hosting costs and compensate for the countless hours and effort I put in to create meaningful and valuable free content I provide to help others succeed.

You've also undoubtedly noticed that I also use various advertising networks - unless of of course you're using an Ad blocker, this is also an attempt to reduce my monthly deficit I experience in providing free relevant, valuable and on occassion insightful content for the benefit of others.

I only really make some money if people click on the ads, unless of course you consider 1c per 1000 impressions real money!

Bear in mind just how many impressions I need to make before I can cover my £20 hosting costs a month!

If you are using an adblocker and guilt stricken you can of course donate using any of the buttons below, but I won't be holding my breath.

Buy me a coffeeBuy me a coffee