Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/git/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Git 不同的密钥和帐户_Git_Github_Bitbucket_Account - Fatal编程技术网

Git 不同的密钥和帐户

Git 不同的密钥和帐户,git,github,bitbucket,account,Git,Github,Bitbucket,Account,有没有办法将ssh配置为对bitbucket(或github)的每个帐户使用不同的密钥 我的意思是,如果我要使用*。bitbucket:user1ssh应该使用keyid\u rsa.user1和for*。bitbucket:user2应该是userid\u rsa.user2 我已经尝试过这样做: IdentityFile ~/.ssh/id_rsa.user1 IdentityFile ~/.ssh/id_rsa.user2 Host *.bitbucket.org:user1* Id

有没有办法将ssh配置为对bitbucket(或github)的每个帐户使用不同的密钥

我的意思是,如果我要使用
*。bitbucket:user1
ssh应该使用key
id\u rsa.user1
和for
*。bitbucket:user2
应该是user
id\u 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

但是没有运气

使用ssh,您可以使用
%HOME%/.ssh/config

(这适用于BitBucket或GitHub)

请参见“”作为示例

然后,
git克隆bitbucketu1:repo1
将从user1克隆repo

#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