SSH配置访问多个repo无法正常工作

时间:2017-05-15 12:31:25

标签: git ssh bitbucket ssh-keys ssh-config

这是配置文件:

Host bitbucket.org
HostName bitbucket.org
User git
IdentityFile ~/.ssh/id_rsa

Host bitbucket-office.org
HostName bitbucket-off.org
User git
IdentityFile ~/.ssh/work_rsa

Host bitbucket-personal.org
HostName bitbucket-per.org
User git
IdentityFile ~/.ssh/personal_rsa

我不知道设置有什么问题。我想从同一台本地机器连接到2个远程回购。设置配置文件是我在互联网上找到的解决方案。但不知何故,我一次只能使用一个(最新创建的那个)。当我尝试从其他仓库中提取时,会抛出以下错误:

Agent admitted failure to sign using the key.
repository access denied.
fatal: The remote end hung up unexpectedly

我的公共SSH密钥都在相应的bitbucket帐户中发布。

如何根据需要运行配置文件?

1 个答案:

答案 0 :(得分:3)

您的HostName设置错误。它们都应该是bitbucket.org,正如您在此设置中所说的实际连接位置。

同样应该缩进Host的设置,但这可能只是一个发布错误。如果它看起来像张贴,这也应该是chnanged。据我所知,缩进很重要而且很有意义。