1.打开终端,Windows用户打开Git Bash
2.执行:
1 | > cd ~/.ssh |
3.生成新的 SSH KEY:
1 | > ssh-keygen -t rsa -C "[email protected]" |
控制台输出:1
2> Generating public/private rsa key pair.
Enter file in which to save the key (/Users/vincen/.ssh/id_rsa):
直接回车,不要修改默认路劲。
提示让输入每次远程操作之前都会要求输入的密码!可以不用输入,直接两次回车:1
2> Enter passphrase (empty for no passphrase):
Enter same passphrase again:
4.生成完毕1
2
3> Your identification has been saved in /Users/vincen/.ssh/id_rsa.
Your public key has been saved in /Users/vincen/.ssh/id_rsa.pub.
The key fingerprint is:
5.添加公钥到GitHub
找到.ssh文件夹,用文本编辑器打开“id_rsa.pub”文件,复制内容到剪贴板。
打开 https://github.com/settings/ssh ,点击 Add SSH Key 按钮,粘贴进去保存即可。