ubuntu 16.04 how to generate SSH key and how to view SSH key
check if SSH Key exists locally
enter
at the terminal
ls -al ~/.ssh
if output is:
No such file or directory
then there is no SSH key
, if you have it, it looks like this:
generates a new SSH key
first enter
in the terminal
ssh-keygen -t rsa -C "[email protected]"
[email protected] for your email address when registering on GitHub or GitLab
enter the terminal will display:
Created directory '/Users/xxx/.ssh'.
Enter passphrase (empty for no passphrase):
The path to save.ssh/ id_RSA is /Users/ XXX /.ssh/ id_RSA, press enter directly.
one thing to note here is that if you already have an SSH key and you want to recreate it using the above it will tell you that you don’t want to regenerate, just type y and press enter.
and the terminal will prompt:
Created directory '/Users/xxx/.ssh'.
Enter passphrase (empty for no passphrase):
You are prompted to set passphrase. You are required to enter passphrase every time you communicate with Git to avoid problems caused by some wrong operation. It is recommended to set it.
after success, the terminal will prompt:
Your identification has been saved in /Users/xxx/.ssh/id_rsa.
Your public key has been saved in /Users/xxx/.ssh/id_rsa.pub.
The key fingerprint is:
16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48 [email protected]
The key's randomart image is:
心形图形
Then input at the terminal:
ssh-add ~/.ssh/id_rsa
You will be asked to enter the Passphrase entered in the above step
after success, the terminal display:
Identity added: /Users/xxx/.ssh/id_rsa (/Users/xxx/.ssh/id_rsa)
Finally, two files are generated in /Users/ XXX /.ssh/, id_RSA and id_Rsa.pub
input at the terminal:
cat /Users/xxx/.ssh/id_rsa.pub
terminal will display your SSH key, just copy it directly.
that’s all ~ ~ O (∩ _ ∩) O ha ha ~