按如下命令來生成 sshkey:
ssh-keygen -t rsa -C "xxxxx@xxxxx.com"
按照提示完成三次回車(設置密碼為空),即可生成 ssh key;
添加后,在終端(Terminal)中輸入:
ssh -T git@gitee.com
若返回 :
Hi XXX! You've successfully authenticated, but Gitee.com does not provide shell access.
則證明添加成功。
將公鑰添加到git服務器;(例如:github; gitee; …)
划重點: 執行ssh-add -K ~/.ssh/id_rsa
將sshkey添加到鑰匙串;
Host ‘git服務器的域名’
HostName ‘git服務器的域名’
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa(私鑰的路徑)
如coding
Host conding.com HostName e.coding.net IdentityFile ~/.ssh/id_rsa_coding