2011-06-11 59 views
6

我有2 github上佔 一個公司一個和個人一個的IntelliJ - 如何使用不同的SSH密鑰

我用cygwin來管理我的SSH密鑰,並連接到Github上

一切工作正常的IntelliJ因爲它使用默認的.ssh/id_rsa密鑰

Everthing在Cygwin中使用我的個人帳戶正常工作,因爲我可以使用「ssh-add〜/ .ssh/ide_rsa_otherkeyfile」命令,然後使用所有通過命令行的git命令

但IntelliJ總是默認爲「id_rsa」文件,因此我無法連接到我的個人回購。

IntelliJ是否有使用其他rsa密鑰的方法?

所有這些RSA和cygwin都超出了我的linux命令行體驗級別。

注: 我也創造了.ssh目錄的配置文件,方便多github上佔

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 

總之這樣做是告訴SSH使用客戶端密鑰連接到服務器時github-客戶端,這真的是github.com。

如果沒有人有解決方案,我知道邀請我的公司帳戶作爲貢獻者會比較容易,但是我必須在2個獨立的電子郵件帳戶下提交。

+0

如果做的IntelliJ尊重配置文件,使用像'GitHub的客戶端地址:aGitRepoName'應該是足夠的IntelliJ使用其他SSH密鑰。 – VonC 2011-06-11 23:23:57

回答

8

Using Git integration

IntelliJ IDEA的支持使用多個ssh密鑰, 通過創建的.ssh /配置文件的裝置的標準方法。

9

從版本控制系統檢出項目時,請使用<host-from-ssh-config>:<github-username>/<repository>格式,如VonC所述。

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

enter image description here

+1

這個作品,應該被接受爲答案! – Czar 2017-02-06 15:27:53