生成新的ssh密钥
进入根目录的.ssh里,没有也行,生成文件名时会生成目录的
cd ~/.ssh
生成文件名和文件位置
ssh-keygen -t rsa -C "github" -f id_rsa_github
指定生成的文件名是id_rsa_github
指定备注是github
密码一般为空即可
此时的~/.ssh目录下会有:
id_rsa_github 私钥文件
id_rsa_github.pub 公钥文件
再把key加到ssh-agent里
Start the ssh-agent in the background.
eval "$(ssh-agent -s)"
Agent pid 59566
If you‘re using macOS Sierra 10.12.2 or later, you will need to modify your ~/.ssh/config file to automatically load keys into the ssh-agent and store passphrases in your keychain.
Host *
AddKeysToAgent yes
UseKeychain yes
IdentityFile ~/.ssh/id_rsa
ssh-add -K ~/.ssh/id_rsa
再把.pub里的加到github的ssh key里
注意:生成的文件名是什么,加到config里的file名字就用自己生成的,ssh-add的也是
此时git clone git://地址 就OK了
参考地址
https://help.github.com/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent/#generating-a-new-ssh-key