Generating SSH keys
Step 1 – Check for existing SSH keys.
ls -al ~/.ssh
# Lists the files in your .ssh directory, if they exist
Check the directory listing to see if you already have a public SSH key. By default, the filenames of the public keys are one of the following:
id_dsa.pub
id_ecdsa.pub
id_ed25519.pub
id_rsa.pub
If you see an existing public and private key pair listed (for example id_rsa.pub and id_rsa) that you would like to use to connect to GitHub, you can skip Step 2 and go straight to Step 3.
Step 2 – Generate a new ssh key
ssh-keygen -t rsa -b 4096 -C "email@email.com"
it will ask you
Generating public/private rsa key pair.
Enter file in which to save the key (/home/jjz109/.ssh/id_rsa):
keep default and just press ENTER
you ‘ll have
Created directory '/xxxxx/.ssh'.
Enter passphrase (empty for no passphrase):
Choose a secure phrase
then
Your identification has been saved in /xxxxxx/.ssh/id_rsa.
Your public key has been saved in /xxxxx/.ssh/id_rsa.pub.
The key fingerprint is:
xx:xx:xx:xx:.............xx:xx email@email.com
The key's randomart image is:
+--[ RSA 4096]----+
| xxxxxx |
| xxxxxxxx |
|xxxxxxxxxxx |
|xx xxx xx |
| * * xx |
|. xxxx |
|..xxx |
|. xxx |
| |
+-----------------+
Step 3 – Add this key to the agent
Be sure ssh agent is running in background
$ eval "$(ssh-agent -s)"
It will give you the PID
Add your SSH key to the ssh-agent:
$ ssh-add ~/.ssh/id_rsa
The result should be : identity added xxxxxxxxxxxx
Step 4 – Add the SSH key to your account
install xclip with apt-get :
sudo apt-get install xclip
xclip -sel clip < ~/.ssh/id_rsa.pub
this will copy your key to the clipboard
Connect to your github account and go in SETTING
select SSH Key
Choose Add key
Past the key you have in your clipboard
SAVE
That’s done
Step 5 – Test the connection
ssh -T git@github.com
This will ask you the passphrase after you said yes to the first question
If the username in the message is yours, you’ve successfully set up your SSH key!