NinjaDeveloper
NinjaDeveloper

Reputation: 43

How to make Eclipse correctly identify which SSH key to use when you're cloning (via git import in eclipse) from two different Github accounts

I have 2 different Github accounts, one personal and one for clients. I have my projects from personal github cloned into Eclipse, however when i am trying to import a project from my second Github account, Eclipse is asking me for the passphrase linked to my personal github account ssh key. I know this because its asking me for the passphrase linked to 'id_rsa'. I am trying to make it use the ssh key 'id_rsa_second_account' but how? Otherwise it just failed to clone because id_rsa key is on my personal account and i want eclipse to use the other key since i am importing a project from my other account! Hope this makes sense, all the help is appreciated.

I've tried adding config file in /.ssh to map the 2 different accounts to the 2 different keys but it provided no help. Eclipse still defaults to using my original key when im trying to import a project from additional github account!

Tried this: How to use multiple Git SSH keys on Eclipse? Didn't help, but no luck. Do i need to edit the URI and edit the [email protected] part perhaps?!

Upvotes: 2

Views: 2404

Answers (1)

Duncan Krebs
Duncan Krebs

Reputation: 3502

I believe what you need to do if you want to use multiple ssh keys for multiple GIT Repos in eclipse is go to preferences, search for SSH in top left and you will see the screenshot below. Make sure all your private and public keys are in the folder you selected in the first field. Then in the second field, add the private keys that you want Eclipse to be able to access. So in your keys you'd have two different accounts two different key sets, put all the private/public keys in the folder you selected in the preference screenshot below (typical /home/.ssh) then click add private key and add the private keys for both accounts you want to clone git repos from. Then after doing that restart eclipse and you should be good, at least this solution works for me. Adding private keys in that second field is important otherwise it won't authenticate and remember to restart eclipse after making preference changes.

Eclipse SSH Preferences

Upvotes: 2

Related Questions