输入如下命令:
ssh-keygen -t rsa -C "liujiaqi@qq.com"
回车后终端会显示:
Generating public/private rsa key pair.
Enter file in which to save the key (/Users/xxx/.ssh/id_rsa):
提示你保存 .ssh/id_rsa 的路径是/Users/xxx/.ssh/id_rsa,直接按回车。
这里有一点,如果已经存在SSH key你想要使用以上操作重新生成的话会提示一你不是要重新生成,直接 输入y并按回车。
然后终端会提示:
Created directory '/Users/xxx/.ssh'.
Enter passphrase (empty for no passphrase):
提示设置 passphrase,每次与 Git 通信都会要求输入 passphrase,以避免某些错误的操作所导致的问题,建议你如果不嫌每次提交都要输入密码麻烦,最好设置一下。
成功后终端会提示:
Your identification has been saved in /Users/smartlei/.ssh/id_rsa_igit.
Your public key has been saved in /Users/smartlei/.ssh/id_rsa_igit.pub.
The key fingerprint is:
SHA256:++Ik2wTYxuEz5UP/G+XEo7ju8pM8SZhol0ifwdZa15U http://igit.58corp.com
The key's randomart image is:
+---[RSA 2048]----+
| .|
| E.|
| ..o. . . |
| =.=+.o ... |
| ..O=SO.. = |
| .++Oo.o = . |
| ...+o.o+ . |
| *o.*. o |
| ..o**o. |
+----[SHA256]-----+