打开终端
1.输入指令:
cd ~/.ssh
2.ls 查看该目录下文件
config id_rsa id_rsa.pub known_hosts
如果有这些说明本地已经有创建SSH
3.创建SSH key
ssh-keygen -t rsa -C "xxx@xxx.com" 填自己GitHub上的邮箱
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/xxx/.ssh/id_rsa):
接下来会提示你输入密码,这个密码是用来每次提交的时候输入确认,(可以不设置,两次回车)
此处因本人已经设置过SSHKey,所以此次操作变成了替换
/Users/xxx/.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 /Users/xxx/.ssh/id_rsa.(id存在的位置)
Your public key has been saved in /Users/xxx/.ssh/id_rsa.pub. (私有key所存在的位置)
5.看到显示结果
The key fingerprint is:
SHA256:5zRejkXCViVHm9xBnRvWEq5eE7swJ8soOexnylXuXB4 xxx@xxx.com
The key's randomart image is:
+---[RSA 3072]----+
| oo*++|
| . . =.B+|
| + . B.+|
| . o . + |
| S + O = |
| . * % B o |
| = * * E |
| o +oo o . |
| ++ o . |
+----[SHA256]-----+
最后成功后会看到类似如下的输出,表示成功生成SSH key了,可以在/.ssh文件夹下看下
- cat id_rsa.pub
看到如下结果
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABgQDfaqpSh/Zqj0KvrYTEiS89gkU8BSyHfAKcetjZH5kbaenso61bYfukwztcs7Kx15jV5Eo8TTuJX77O67H3Xx+YQIb44JS/+p0NYUt9luS+9xmo/A9KRlM25bSGambSygm4wEpNpqg1cjJWQiSLJiHX9bg6pHFTH9t+mtpnf7zN7tr3osinoSKwHFYSka6wyUc3PVDTio7sUiF67IzmOBXx4429MVsRn1bj3s0WW4Zl5kcton4l+cU85DGZzzgzwLQJ0wdnqtCmzO6JD796RNkGayTZ2JQwK6whjdtqNKz//eztPafwb4Lz+sCASTiVCCM/yBkpxi0AvAHkHQYVYnaQMaD15usTRLqjWQXVxfjCflstH+IlBQeRr5sKrTHbEiPc98UgBp449GmuJxciW7N2OTMaKlGz3DJ1uvs3gdUWBf3s2l0ALhbPXNQadXhuTGrisZVjOiZ7c8od4CQW7MSwu7HogEA3IpFCzq3VcX9e7Vf+w1zf64aiCmvuUkR5cDs= xxx@xxx.com
//这就是你的key值了
网友评论