Set up GitHub using a SSH key on Ubuntu 16.04

If not already installed, install Git using the following code in Terminal:

 sudo apt install git 

It is possible to install git-all instead of git, but if working in just the console git is sufficient as well has being a significantly more lightweight package.

If a SSH key has not already been generated, this can be done using the following code in Terminal:

 ssh-keygen -t -rsa 

Log into the GitHub website and go to Settings then SSH and CPG keys, copy and paste here the generated public key found in your file.

Test the SSH connection using the following code:

 ssh -T 

SSH access to GitHub is working correctly if you are met with the message: “Hi USERNAME! You’ve successfully authenticated, but GitHub does not provide shell access.”.

The name and email address used for commits also needs to be configured using the following code in Terminal, (replacing FULL_NAME with your name (not username), and EMAIL with your email address):

 git config --global "FULL_NAME" 
 git config --global "EMAIL" 

The configuration can be checked using the following code:

 git config --global 
 git config --global 

A repository can now be cloned using SSH, visit the repository on the GitHub website and click Clone or Download, if it is not already set to SSH click Use SSH then copy and paste the SSH link provided into the code below:

 git clone ssh:// 

The repository should now be cloned and ready to use.



Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s