更新时间:2023-11-22 19:50:52
主机bitbucket bitbucket。有机
?您不要在一个主机
部分声明多个条目名称。
我希望在ssh config中看到文件声明多个键:
主机bitbucketuserA
主机名bitbucket.org
IdentityFile〜/ .ssh / id_rsa
用户git
主机bitbucketuserB
主机名bitbucket.org
IdentityFile〜/ .ssh / other
用户git
你可以像使用ssh url一样使用
bitbucketuserA:userA / myrepo1
bitbucketuserB:userB / myrepo2
(这与我建议如何处理办公室计算机的个人GitHub回购,其SSH密钥已添加到工作相关的GitHub帐户?)
I looked several answers and forums for a solution but I could not find a single one that works.
I have this scenario:
~/.ssh
folderI created a ~/.ssh/config
file with the contents:
Host bitbucket bitbucket.org
Hostname bitbucket.org
IdentityFile ~/.ssh/id_rsa
IdentityFile ~/.ssh/other
User git
And for the sake of sanity I added the second key using ssh-add
as well. Running ssh-add -l
lists both keys.
When using the command line, all git commands work like a charm, with both repositories. But when using Eclipse, I always get the Invalid remote: origin
error when trying to clone or pull from the repository with the secondary key:
Caused by: org.eclipse.jgit.errors.NoRemoteRepositoryException: git@bitbucket.org:myuser/myrepository.git: conq: repository access denied.
I added the secondary key at Window > Preferences > Network Connections > SSH2 > Private keys
, and set the GIT_SSH
environment variable to point to my ssh
executable:
$echo $GIT_SSH
/usr/bin/ssh
I've restarted Eclipse and even the OS several times, with no luck.
Since I can use git from the command line without problems, I tend to believe there's something wrong with Eclipse.
How to use multiple Git SSH keys on Eclipse? Or how to force Eclipse to use my secondary key on a single project?
Host bitbucket bitbucket.org
? You don't declare multiple entry names on one Host
section.
I would expect to see in a ssh config file declaring multiple keys:
Host bitbucketuserA
Hostname bitbucket.org
IdentityFile ~/.ssh/id_rsa
User git
Host bitbucketuserB
Hostname bitbucket.org
IdentityFile ~/.ssh/other
User git
And you would use ssh url like
bitbucketuserA:userA/myrepo1
bitbucketuserB:userB/myrepo2
(this is similar to what I suggested for "How to work on personal GitHub repo from office computer whose SSH key is already added to a work related GitHub account?")