How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

July 9, 2018
How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

“How to Add an SSH Public Key to GitHub from an Ubuntu 18.04 LTS System” covers the entire process of creating an SSH key pair on an Ubuntu 18.04 LTS system and adding the public key to GitHub. Adding the public SSH key to GitHub will make commits much quicker and smoother as commits performed via SSH do not require a username and password. The security measures provided by SSH keep projects safe from prying eyes as well.

This tutorial assumes that you have already created a GitHub account. If you have not yet created a GitHub account, please follow this tutorial about creating an account and installing git on your Ubuntu system before continuing with this tutorial.

1. The first thing that we need to do is create an SSH key pair to use. Creating this key pair will allow us to add the public key to GitHub. Open a terminal and enter the following command to create the SSH keypair:

ssh-keygen
How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

2. After entering the command, a prompt appears with a default file path confirmation. Press Enter to accept the default file path.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

3. Next, a password prompt appears. Our goal is convenience, since our public key is being created exclusively for GitHub. Leave the passphrase empty and press Enter.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

4. Another prompt appears, this time asking for the passphrase confirmation. Leave this prompt blank as well and press Enter.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

5. After passphrase confirmation, our SSH key pair is created and saved within the default file path that we accepted in step 2 of this tutorial. We will need to copy the entire contents of our public key to add to GitHub. To display the contents of the public key, enter the following command into the terminal:

cat ~/.ssh/id_rsa.pub
How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

6. The output of the previous command should display the contents of the public key like in the image below.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

7. Highlight and copy the entire output of the previous command. Every part must be copied for the SSH key to work when added to GitHub.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

8. Now that the public SSH key has been copied to the clipboard, open a web browser and navigate to GitHub, then log in to your account.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

9. Click the account icon on the navigation bar on the top-right of the page. Select ‘Settings’ from the dropdown menu that appears.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

10. Select ‘SSH and ‘GPG keys’ from the selection pane on the left of the page.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

11. Click the green, ‘New SSH key’ button on the top-right of the page.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

12. We are taken to the ‘Add New SSH Key’ page. First, enter an identifying title for the SSH key so discerning which computer the matching private key is on is easy.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

13. Finally, paste the public SSH key that was copied in step 7 of this tutorial into the ‘Key’ text field.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

14. Click the green, ‘Add SSH key’ button to finish the process.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS

15. Success! The new public SSH key has been added to the GitHub account and can now be used to simplify and secure your work.

How to Add an SSH Public Key to GitHub from Ubuntu 18.04 LTS