MAC 配置ssh允许SourceTree通过秘钥访问远程仓库

按如下命令来生成 sshkey:

ssh-keygen -t rsa -C "[email protected]"

按照提示完成三次回车(设置密码为空),即可生成 ssh key;

添加后,在终端(Terminal)中输入:

若返回 :

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

猜你喜欢

转载自www.cnblogs.com/qxandxt/p/12451817.html