How To Add Ssh Key To Github
How to add SSH key to github account?
Since August 13th 2021 Github has removed support for using account password for authenticating Git operations. You can read more about that here.
To authenticate git operations you can now use:
Easiest and simplest way to authenticate git operations is using SSH key.
In order to generate SSH key, run following command:
ssh-keygen -t rsa -b 4096 -C "your_email@example.com"
After that, press
- To keep default file for saving ssh key
- Passphrase
- Repeat passphrase
After SSH key generation command, output will be:
Your public key has been saved in /home/user/.ssh/id_rsa.pub
Next step is to copy public SSH key to your github account.
You can get contents of the id_rsa.pub
file as follows:
cat /home/user/.ssh/id_rsa.pub
Bear in mind that path to id_rsa.pub
may differ and you have to change
it accordingly.
Output of the cat
command is something like:
ssh-rsa lot_of_random_letters_and_numbers...==<my_email>@gmail.com
Copy contents of id_rsa.pub
and do following:
- Log-in to your github account
- Press white downwards pointing arrow in the upper-right corner beside your profile picture to open drop-down menu
- Press Settings in drop-down menu
- After opening Settings on the left side of the page click on
SSH and GPG keys
- After opening
SSH and GPG keys
click on the green button that says New SSH key - Type in title for your SSH key (usually PC or container name)
- Paste contents of
id_rsa.pub
(SSH key) bellow title in Key window - Press Add SSH key
Verify that you’ve added ssh key as follows:
ssh -T git@github.com
If you’ve added SSH key you will get output like:
> Hi USERNAME! You've successfully authenticated, but GitHub does not
> provide shell access.
More about SSH you can read here.