无法使用具有不同身份的 Mercurial SSH 到 BitBucket
Can't SSH to BitBucket with Mercurial with different identities
所以我刚刚在 Bitbucket 上设置了第二个帐户,我将它与 mercurial 一起使用,就像第一个帐户一样。我已按照说明 here 进行操作,因此我的 ~/.ssh/config
文件如下所示:
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
ForwardAgent yes
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/personal
现在,我只能使用文件上的第一个身份进行 SSH,而对于第二个身份,我得到:
remote: conq: repository access denied.
abort: no suitable response from remote
如果我在 config
文件上切换两个身份,那么我可以使用以前无法访问的身份访问,反之亦然。我究竟做错了什么?
更改 .ssh/config
中的主机别名:
.ssh/config
Host bitbucket1
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host bitbucket2
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/personal
用法
# will use the ~/.ssh/id_rsa identity
hg clone ssh://hg@bitbucket1/your/repository
# will use the ~/.ssh/personal identity
hg clone ssh://hg@bitbucket2/your/repository
您可以使用任何 ssh 别名,唯一重要的是它们对于不同的身份是不同的。因此,您可以为第一个条目保留 Host bitbucket.org
,并将另一个条目更改为 Host personal.bitbucket.org
。
所以我刚刚在 Bitbucket 上设置了第二个帐户,我将它与 mercurial 一起使用,就像第一个帐户一样。我已按照说明 here 进行操作,因此我的 ~/.ssh/config
文件如下所示:
UserKnownHostsFile /dev/null
StrictHostKeyChecking no
ForwardAgent yes
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host bitbucket.org
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/personal
现在,我只能使用文件上的第一个身份进行 SSH,而对于第二个身份,我得到:
remote: conq: repository access denied.
abort: no suitable response from remote
如果我在 config
文件上切换两个身份,那么我可以使用以前无法访问的身份访问,反之亦然。我究竟做错了什么?
更改 .ssh/config
中的主机别名:
.ssh/config
Host bitbucket1
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/id_rsa
Host bitbucket2
HostName bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/personal
用法
# will use the ~/.ssh/id_rsa identity
hg clone ssh://hg@bitbucket1/your/repository
# will use the ~/.ssh/personal identity
hg clone ssh://hg@bitbucket2/your/repository
您可以使用任何 ssh 别名,唯一重要的是它们对于不同的身份是不同的。因此,您可以为第一个条目保留 Host bitbucket.org
,并将另一个条目更改为 Host personal.bitbucket.org
。