为github/gitlab生成SSH Key
为github/gitlab生成SSH Key步骤一:设置你的本地账户步骤二: 生成本地秘钥步骤三: 复制公钥步骤四:将key添加到github或gitlab中步骤一:设置你的本地账户打开console并输入如下两个命令:git config --global user.name "liujiaqi"git config --global user.email "liujiaqi...
·
为github/gitlab生成SSH Key
步骤一:设置你的本地账户
打开console并输入如下两个命令:
git config --global user.name "liujiaqi"
git config --global user.email "liujiaqi@qq.com"
步骤二: 生成本地秘钥
输入如下命令:
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]-----+
步骤三: 复制公钥
根据步骤二中提示的地址路径,用vim复制key的内容:vim ~/.ssh/id_rsa.pub,右键复制出现的内容,如图:

步骤四:将key添加到github或gitlab中
根据下图,将刚才的复制的keys粘贴即可



更多推荐
所有评论(0)