Add a SSH key for your github account

Mir Sahib
2 min readNov 14, 2020
Image for attention

Why Use SSH Key

When working with a GitHub repository, you’ll often need to identify yourself to GitHub using your username and password. An SSH key is an alternate way to identify yourself that doesn’t require you to enter you username and password every time.

Prerequisite:
Linux OS
Window with powershell (not test by me)

How to generate a SSH key

Goto to your linux terminal and type the following command

cd ~/.ssh
ls

This will move you to ~/.ssh director and show you the existing ssh key (if you are new to generating ssh key you directory maybe empty)

ssh-keygen -o -t rsa -C "your@email.com"

This command with generate some question for you which are:

Generating public/private rsa key pair.
Enter file in which to save the key (/Users/username/.ssh/id_rsa):
Enter passphrase (empty for no passphrase):Enter same passphrase again:

Passphrase is making your key more secure so giving a passphrase is optional.After submitting the answer you will get the following message

Your identification has been saved in /Users/username/.ssh/id_rsa.
Your public key has been saved in /Users/username/.ssh/id_rsa.pub.
The key fingerprint is:
01:0f:f4:3b:ca:85:d6:17:a1:7d:f0:68:9d:f0:a2:db your@email.com
The key's randomart image is:
+--[ RSA 2048]----+
| |
| |
| . E + |
| . o = . |
| . S = o |
| o.O . o |
| o .+ . |
| . o+.. |
| .+=o |
+-----------------+

Add you SSh public key to your github account

Paste the following command

cat ~/.ssh/id_rsa.pub

Output of the command should be similar like this

ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA879BJGYlPTLIuc9/R5MYiN4yc/YiCLcdBpSdzgK9Dt0Bkfe3rSz5cPm4wmehdE7GkVFXrBJ2YHqPLuM1yx1AUxIebpwlIl9f/aUHOts9eVnVh4NztPy0iSU/Sv0b2ODQQvcy2vYcujlorscl8JjAgfWsO3W4iGEe6QwBpVomcME8IU35v5VbylM9ORQa6wvZMVrPECBvwItTY8cPWH3MGZiK/74eHbSLKA4PY3gM4GHI450Nie16yggEg2aTQfWA1rry9JYWEoHS9pJ1dnLqZU3k/8OWgqJrilwSoC5rGjgp93iu0H8T6+mEHGRQe84Nk1y5lESSWIbn6P636Bl3uQ== your@email.com

Copy the content of your terminal and go to your Github account->Setting->SSH and GPG keys
Click New SSH key button at the right side of your screen,In the tile section give your key a name (i have given my computer name,every pro developer has a name for there computer its a tradition) paste your copied key to the key section and clicked Add SSH Key.Voila, now you can push your code without asking for username and password everytime.
NB: This procedure only work if you use SSH as your git remote url

--

--

Mir Sahib

Full Stack Developer | Aspiring Data Scientist | Avid Arsenal Fan