Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IntelliJ - How to use a different ssh key

I have 2 github accounts A company one and a personal one

I use cygwin to manage my ssh keys and connect to Github

Everything works fine In IntelliJ when using the corporate account since it uses the the default .ssh/id_rsa key

Everthing works fine in Cygwin using my Personal Account since I can use the the "ssh-add ~/.ssh/ide_rsa_otherkeyfile" command and then use all git commands via command line

But IntelliJ always default to the "id_rsa" file so I can not connect to my personal repo.

Is there a way for IntelliJ to use the other rsa key?

All this RSA and cygwin is way above my linux command line experience level.

Note: I also created the config file in .ssh directory to facilitate multiple github accounts

Default GitHub user (corporate account) 
Host github.com HostName
github.com User git IdentityFile/Users/username/.ssh/id_rsa

Client user (personal account)
Host github-client
HostName github.com
User git IdentityFile /Users/username/.ssh/id_rsa_perso

In short what this does is tells SSH to use the client key when connecting to the server github-client, which is really github.com.

If no one has a solution I am aware that it would be easier to invite my corporate account as a contributor but then I woul have commits under 2 seperate email account.

like image 790
Stephane Rainville Avatar asked Jun 11 '11 23:06

Stephane Rainville


2 Answers

When checking out your project from Version Control System, use <host-from-ssh-config>:<github-username>/<repository> format as VonC mentioned.

$ cat ~/.ssh/config
Host github.com-activehacker
    HostName github.com
    User git
    IdentityFile /Users/andrey/.ssh/id_rsa_activehacker

enter image description here

like image 186
kukido Avatar answered Sep 23 '22 22:09

kukido


From Using Git integration:

IntelliJ IDEA supports the standard method of using multiple ssh keys, by means of creating .ssh/config file.

like image 20
David206 Avatar answered Sep 21 '22 22:09

David206