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: [email protected]: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?")
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With