2个github账号,分别是
ssh-keygen -t rsa -C ‘myself_account@A.com‘ -f ~/.ssh/id_rsa_myself
ssh-keygen -t rsa -C ‘mycompany_account@B.com‘ -f ~/.ssh/id_rsa_mycompany
Host github.com
HostName github.com
IdentityFile ~/.ssh/id_rsa_myself
IdentitiesOnly yes
Host github-mycompany
HostName github.com
IdentityFile ~/.ssh/id_rsa_mycompany
IdentitiesOnly yes
ssh-agent bash
ssh-add ~/.ssh/id_rsa_myself
ssh-add ~/.ssh/id_rsa_mycompany
ssh -T git@github.com
ssh -T git@github-mycompany
可以连接的话,会返回消息
Hi XXX! You‘ve successfully authenticated, but GitHub does not provide shell access.
之后myself_account使用的时候,因为Host配置的github.com,可以正常使用,而mycompany_account账号clone的时候,要将github.com替换为github-mycompany
git clone git@github-mycompany:XXX/YYY.git
clone后注意配置下用户邮箱和名字就可以了
原文:https://www.cnblogs.com/wendelhuang/p/15122016.html