How to Set Up SSH Key for GitHub from Your Local PC/Server

A guide on setting up an SSH key for GitHub as well as Local PC/Server.

Akshay Krison
2 min readNov 18, 2021
SSH-KEY Authentication With GitHub

SSH keys are an authentication method used to gain access to an encrypted connection between systems and then ultimately use that connection to manage the remote system.

Open the Terminal for Linux users. For Windows users, open PowerShell or Gitbash and type the command shown below:

ssh-keygen
ssh key generation

Click enter to ask a question for generating public/private rsa key pair then click Enter (Note the ssh-key generated path as /root/.ssh/)

confirm the path to generate ssh-key

After that, you will get a success message in your console. Then we need to view and copy the public key, to our GitHub account for which we need to change our directory to the above path where our key file is stored. For me the path is /root/.ssh/.

cd /root/.ssh/

Then type ls for listing the folder/files inside the current directory and you will get the folders and files inside the directory. Then open the public key where you can find two keys: one is private (id_rsa) and another one is the public key (id_rsa.pub). For opening the key use the below command:

cat id_rsa.pub 

Which will open your key on the console:

Public SSH-KEY

Copy the entire code. In my case, I copied from ssh-rsa to 01 and pasted it in the GitHub console. In the console, go to the account section in the settings and click on the SSH and GPG Key. Then click on the New SSH Key and you will get a console like the below image. There, type the Title as Your PC Name and Paste the code you copied in the Key section.

Add SSH Key to Github

Then Click Add SSH Key and You are done!

That's how it’s done. Thank you for reading.

More content at plainenglish.io

--

--