Generate and Configure Git SSH Key on Linux

July 10, 2015 | Last tested: October 2015 | 1601 views | Comments

Simply generate an ssh-key and add it's public key to your GitHub account to be able to authorize your computer to remotely login and connect to it.

This has been tested on Ubuntu OS, but should fairly work the same on other Linux Distributions.


Notes: If you are using an existing ssh key, proceed to Step 2.


Step 1. Generate a new SSH key

Open a terminal and type ssh-keygen -t rsa -b 4096 -C "".

$ ssh-keygen -t rsa -b 4096 -C ""


You will be asked where to save the file, just hit enter


Enter a hard-to-guess passphrase. Do not forget your passphrase, you will be needing this in your future ssh connections.


SSH key has been created.


Step 2. Open ssh agent and add your key to it.

$ eval "$(ssh-agent -s)"
$ ssh-add ~/.ssh/id_rsa


Step 3. Add your SSH key to your github account.

Step 3.1.

Open the file Just leave it open in the meantime, you will copy all of it's contents later.

$ gedit ~/.ssh/


Step 3.2.

Login on github and click the View profile and more link located at upper right corner of the page.


Step 3.3.

Select Settings.


Step 3.4.

Click SSH Keys.


Step 3.5.

Click Add SSH Key.


Step 3.6.

On the Title field, type something that would remind you in the future that you are the one who added such SSH key. Next, is the time to copy all that's inside to the field Key. Lastly, click Add key.

It will appear on the list of keys. You can now close file, and log out your github account.


What's Next? Test the ssh connection.

Enter ssh -T on the terminal.

$ ssh -T

Your ssh connection was successful when you see a message similar below.


Related Tutorials

Must Read