How to set up an ssh key for Github
Having an ssh key for GitHub will save us from writing username and password while performing a git action on a repository. In this article, we will cover how we can add an ssh key for our GitHub account.
First, we will generate an ssh key through our terminal
ssh-keygen -t rsa -b 4096 -C “email@domain.com”
-t denotes type, -b denotes the number of bytes, -C denotes the email to which you want to assign the key
You will be prompted to enter the location of the key and a passphrase, my suggestion would be to leave it blank and just press enter. Having no passphrase will save you from the trouble of entering it every time you make a commit to a repo.
After setting password and folder location you need to set ssh to a ssh-agent through the below commands
eval “$(ssh-agent -s)”
ssh-add ~/.ssh/id_rsa
Now you have an ssh key which you just have to paste into your GitHub account. You can print the ssh key by below command
cat ~/.ssh/id_rsa.pub
and copy it.
Now go to your Github account >> profile >> SSH and GPG keys
You need to paste your ssh key in the key field as shown in above image and give it a title and click “Add SSH key” in bottom.
Congratulations you have added an ssh key to your GitHub account.