有时候和别人在github上合作开源项目时,添加别人的SSH keys的时候,会提示key已经在使用中了。这是因为这个ssh公钥已经使用在另一个账号上了。那就需要ssh多账号了。
1、生成另一个秘钥名称不一样的(我这里是id_rsa_useosc,原先的是id_rsa)
2、在~/.ssh中添加一个config文件,配置内容:
Host github-useosc
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa_useosc
User git
Host github-pigeatrock
HostName github.com
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
User git
这样对远程库的操作要变换下:
原先的add
git remote add useosc git@github.com:useosc/banbanjia-wxapp.git
现在的add
git remote add useosc git@github-useosc:useosc/banbanjia-wxapp.git
其他的操作步骤同以前