2013-02-18 233 views
1

任何配置ssh使用不同的密鑰爲每個帳戶的bitbucket(或github)?Bitbucket不同的密鑰和帳戶

我的意思是,如果我要與*.bitbucket:user1 ssh來工作應該使用鍵id_rsa.user1*.bitbucket:user2應用戶id_rsa.user2

有沒有做試了一下:

IdentityFile ~/.ssh/id_rsa.user1 
IdentityFile ~/.ssh/id_rsa.user2 

Host *.bitbucket.org:user1* 
    IdentityFile ~/.ssh/id_rsa.user1 
    User git 

Host *.bitbucket.org:user2* 
    IdentityFile ~/.ssh/id_rsa.user2 
    User git 

,但沒有運氣。

回答

3

使用ssh,您可以使用%HOME%/.ssh/config輕鬆地命名您的ssh遠程以使用一組密鑰或另一組密鑰。
(這適用於到位桶或GitHub的)

見,例如, 「change github account mac command line

#User 1 on BitBucket 
Host bitbucketu1 
    HostName bitbucket.org 
    User git 
    IdentityFile ~/.ssh/id_rsa.user1 

#User 2 on BitBucket 
Host bitbucketu2 
    HostName bitbucket.org 
    User git 
    IdentityFile ~/.ssh/id_rsa.user2 

然後,將git clone bitbucketu1:repo1克隆從user1的回購。

相關問題