多git账号ssh公钥管理方式

来源:互联网 发布:重庆行知职业技术学校 编辑:程序博客网 时间:2024/05/21 12:13

背景:

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

解决方案:

touch ~/.ssh/configvi ~/.ssh/config

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

Host realname.example.com(仓库1)    HostName realname.example.com    IdentityFile ~/.ssh/realname_rsa # private key for realname    User remoteusernameHost 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

0 0