2013-07-13 48 views
1

我有2個git賬戶在我的Mac上,我有2套公鑰和私鑰。
我在/.ssh一個配置文件來管理這些帳戶,它看起來像這樣:Git與多個帳戶給出相同的用戶名,同時做ssh

Host github.com 
    HostName github.com 
    User git 
    IdentityFile ~/.ssh/id_rsa 

Host github-user2 
    HostName github.com 
    User git 
    IdentityFile ~/.ssh/id_rsa_user2 

代碼從這些帳戶將被推到了我的設置不同的遙控器在各自的2個不同的遠程倉庫目錄使用以下命令:

git remote add origin github.com:xyz_user/abc.git 
git remote add origin github-user2:pqr_user/def.git 

我成功地從這兩個帳戶推送到這些回購。
當我使用ssh,

ssh-add -l 

顯示私鑰兩個賬戶的添加。

ssh -T github.com 
ssh -T github-user2 

都提供了以下消息:

"Hi user2! You've successfully authenticated, but GitHub does not provide shell access." 

1兩件事,我已經注意到了,即使沒有與 「SSH-添加-l」

ssh -T github.com & ssh -T github-user2 provide successful authenticate message. 
上市的關鍵

如何在使用ssh連接時區分兩個帳戶?
ssh -T從哪裏進行身份驗證?

回答

1

如何在使用ssh連接時區分兩個帳戶?

你不會真的這兩個公鑰已經在同一個GitHub帳戶中註冊,因此就GitHub而言,這兩個ssh都認證你爲'user2'。

ssh -T認證來自哪裏?

它正在尋找您的Account profilessh keys section
這兩個公鑰都在那裏註冊,如GitHub help page on "Generating SSH Keys"中所述。

+0

嗨馮,謝謝你的回覆。但是,兩個公鑰都在不同的GitHub帳戶中註冊。 – Manu

+0

@Manu是否有可能在兩個GitHub賬戶中都複製公鑰? – VonC

+0

@Manu也在這裏看到(https://gist.github.com/jexchan/2351996)一個成功的雙帳戶ssh設置的例子。 – VonC

相關問題