bitbucket / github上多个帐户的多个ssh密钥,无法正常工作

时间:2014-07-20 16:22:05

标签: git ssh

即使对这个话题有很多疑问,我也很难尝试这项工作。要么我缺少某些东西,要么他们不是我想要的东西。

我在github上有两个帐户 - account1account2及其各自的存储库

git@bitbucket.org:account1/repo.git
git@bitbucket.org:account2/repo.git

在我的电脑上,我为每个account1_id_rsaaccount1_id_rsa创建了2个单独的SSH密钥

当我将它们命名为id_rsa时,它们都可以单独工作,默认情况下它们都可以正常工作。但是我希望能够保持名为account1_id_rsaaccount1_id_rsa的键,并且仍然可以推/拉而不必根据我当前想要处理的回购重命名每个键。

在阅读了关于该主题的许多QA之后,我仍然无法弄清楚要放在.ssh\config中的内容。到目前为止我已经尝试了

Host           bitbucket
HostName       bitbucket.org
IdentityFile   ~/.ssh/account2_id_rsa
User           account2
Host           bitbucket
HostName       bitbucket.org
IdentityFile   ~/.ssh/account1_id_rsa
User           account1

1 个答案:

答案 0 :(得分:0)

在这里找到答案

http://kevinpelgrims.com/blog/2012/07/19/setting-up-multiple-github-accounts-on-windows

Host           account1.bitbucket
HostName       bitbucket.org
IdentityFile   ~/.ssh/account1_id_rsa
Host           account2.bitbucket
HostName       bitbucket.org
IdentityFile   ~/.ssh/account2_id_rsa

最重要的是,我需要有以下git网址

git@account1.bitbucket.org:repo.git
git@account2.bitbucket.org:repo.git
相关问题