Signup/Sign In
PUBLISHED ON: AUGUST 26, 2021

How to Setup SSH keys on GitHub?

SSH stands for Secure Shell and it is a network protocol that allows us to communicate with remote servers.

SSH uses two keys - a Public Key and a Private Key. The public key is shared with the remote server while the private key is kept by the user.

The server authenticates the client by sending a Locked message(using the public key) and the client Unlocks this message and sends it back to the server for verification.

Let's learn how to set up a public SSH key on GitHub.

SSH illustration

Adding SSH Key on GitHub

SSH keys are stored in the .ssh folder in our home directory. We can view the files present in this folder by using the ls command.

$ ls -al ~/.ssh

Viewing the SSH keys

Use the cat command to view the content of the public key and copy it. The public key is the one ending with the .pub extension.

$ cat ~/.ssh/id_rsa.pub

Copying the public key

Now, log in to your GitHub account and go to your account setting and click on the SSH and GPG Keys tab and click on the New SSH Key button.

Click on SSH and GPG keys and add a new key

Enter a suitable title for the key and paste the copied public key in the space provided and click on the Add SSH Key button. You will be asked to enter your GitHub profile password.

Adding a title to our key

You will be able to view the key in the SSH and GPG Keys section.

Viewing the key on GitHub

To test whether our SSH key was successfully added, run the following command. If it gives an output similar to the one shown below then the key was properly set up.

$ ssh -T git@github.com

Checking the setup was successful or not.

Summary

SSH keys are an easy and secure way of communicating with the remote repository. SSH is a network protocol and SSH keys provide a Lock and Key system for user authentication.

To establish the connection, we have to set up our public key on the Git hosting website. In this tutorial, we learned how to set up SSH keys on GitHub.



About the author:
I like writing content about C/C++, DBMS, Java, Docker, general How-tos, Linux, PHP, Java, Go lang, Cloud, and Web development. I have 10 years of diverse experience in software development. Founder @ Studytonight