ssh -keygen -t rsa -C “youremail” 创建密匙
1 创建SSH Key
在用户主目录下,看看有没有.ssh目录,再看看这个目录下有没有id_rsa和id_rsa.pub,这两个文件这两个就是SSH Key的秘钥对,id_rsa是私钥,id_rsa.pub是公钥。如果没有,打开Shell,创建SSH Key:
[root@localhost ~]# cd ~
[root@localhost ~]# ll
总用量 44
drwxr-xr-x. 3 root root 18 11月 12 15:58 222
drwxrwxr-x. 29 root root 24576 11月 11 16:32 git-2.29.2
-rw-r--r--. 1 root root 25 11月 7 22:18 wang.sh
[root@localhost ~]# ssh-keygen -t rsa -C "2291106509@qq.com" (生成秘钥)
Generating public/private rsa key pair.
Enter file in which to save the key (/root/.ssh/id_rsa):
/root/.ssh/id_rsa already exists.
Overwrite (y/n)? y
Enter passphrase (empty for no passphrase):
Enter same passphrase again:
Your identification has been saved in /root/.ssh/id_rsa.
Your public key has been saved in /root/.ssh/id_rsa.pub.
The key fingerprint is:
SHA256:9aHRFRSDQMamxmcF8WAR6xQgPocl8mxsbHCRpS3VuI0 2291106509@qq.com
The key's randomart image is:
+---[RSA 2048]----+
| o =+=*%* o*o |
| X.O.o+*o. . |
| #.o*=.+ |
| + +E+++ . |
| .Soo . |
| |
| |
| |
| |
+----[SHA256]-----+
[root@localhost ~]#
2 登陆Github
打开“Account settings”,“SSH Keys”页面:
然后,点“Add SSH Key”,填上任意Title,在Key文本框里粘贴id_rsa.pub文件的内容
点“Add Key”,你就应该看到已经添加的Key: