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.
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
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
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.
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.
You will be able to view the key in the SSH and GPG Keys section.
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 firstname.lastname@example.org
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.