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


按如下命令来生成 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

 


免责声明!

本站转载的文章为个人学习借鉴使用,本站对版权不负任何法律责任。如果侵犯了您的隐私权益,请联系本站邮箱yoyou2525@163.com删除。



 
粤ICP备18138465号  © 2018-2025 CODEPRJ.COM