使用ssh-keygen
生成公钥私钥
itaken@itaken-home:~/.ssh$ ssh-keygen -t ed25519 -C "regelhh@gmail.com"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/itaken/.ssh/id_ed25519): id_itaken
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in id_itaken.
Your public key has been saved in id_itaken.pub.
The key fingerprint is:
SHA256:n15ib9VEA09Kma8UcVKyXLUjpPkJ/B/ATlj5XX6bc8 regelhh@gmail.com
The key's randomart image is:
+--[ED25519 256]--+
| %=*OB|
| oB%**|
| ..oO=@o|
| .. o+oB +|
| S o0o. O|
| o.+= .|
| .= E |
| 0. . |
| Oo.. |
+----[SHA256]-----+
itaken@itaken-home:~/.ssh$ ll
总用量 40K
-rw-r--r-- 1 itaken itaken 372 5月 15 2020 config
-rw------- 1 itaken itaken 464 5月 29 21:35 id_itaken
-rw-r--r-- 1 itaken itaken 99 5月 29 21:35 id_itaken.pub
-rw-r--r-- 1 itaken itaken 3.9K 3月 29 17:41 known_hosts
Add your SSH private key to the ssh-agent
itaken@itaken-home:~/.ssh$ ssh-add id_itaken
Enter passphrase for id_itaken:
Identity added: id_itaken (regelhh@gmail.com)
打开https://github.com/settings/keys
,查看cat id_itaken.pub
公钥,将公钥复制到github的key
中
itaken@itaken-home:~/.ssh$ cat id_itaken.pub
ssh-ed25519 AAACAzaC13NlZDI1NTE3LE5AAIXX4AM+l7WYXio89Iy5DBqlk42BAYPMu4eBhm5mvMBK regelhh@gmail.com