多git账号ssh公钥管理方式

背景:

公司有两个git仓库域名地址,我有两个git账号分别去登陆,但不同git仓库连接所使用的id_rsa私钥和id_rsa.pub公钥也不一样。

解决方案:

touch ~/.ssh/config
vi ~/.ssh/config

输入下面对应修改的信息:

Host realname.example.com(仓库1)
    HostName realname.example.com
    IdentityFile ~/.ssh/realname_rsa # private key for realname
    User remoteusername

Host realname2.example.org(仓库2)
    HostName realname2.example.org
    IdentityFile ~/.ssh/realname2_rsa
    User remoteusername

参考资料:

https://gist.github.com/yeungeek/596984fd9e53d6c36c0d
http://stackoverflow.com/questions/2419566/best-way-to-use-multiple-ssh-private-keys-on-one-client

猜你喜欢

转载自blog.csdn.net/g19920917/article/details/52473079
今日推荐