从我的笔记本电脑在 Bitbucket 上使用多个帐户的最佳方式
Best way to use multiple accounts on Bitbucket from my laptop
我有 2 个 Bitbucket 帐户:
我在这 2 个帐户上添加了所有必需的 SSH 密钥(一切正常)。
在我的配置文件中(在 ~/.ssh 目录下):
Host bitbucket.org - myaccount1
User git
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/myaccount1
Host bitbucket.org - myaccount2
User git
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/myaccount2
但是,我无法从我的 Git 客户端访问(身份验证错误)myaccount2。对于 myaccount1 它是完美的,它有效。
如果我想访问myaccount2,我必须删除配置文件中关于myaccount1 的所有信息。我刚才在这个文件中有:
Host bitbucket.org - myaccount2
User git
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/myaccount2
这样就可以了,我可以正常访问myaccount2了
如何正确配置此配置文件以保持我对这 2 个帐户的访问权限?
非常感谢你们!
您的配置文件在 Host
中具有相同的名称:"bitbucket.org"。
您需要为每一个起一个不同的名称,然后相应地调整您的 git 遥控器 url。
例如:
Host bitbucket.org
User git
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/myaccount1
Host othername
User git
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/myaccount2
然后:
git clone git@othername/whatever.git
将从 myaccount2
克隆
更多信息here
我有 2 个 Bitbucket 帐户:
我在这 2 个帐户上添加了所有必需的 SSH 密钥(一切正常)。
在我的配置文件中(在 ~/.ssh 目录下):
Host bitbucket.org - myaccount1
User git
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/myaccount1
Host bitbucket.org - myaccount2
User git
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/myaccount2
但是,我无法从我的 Git 客户端访问(身份验证错误)myaccount2。对于 myaccount1 它是完美的,它有效。
如果我想访问myaccount2,我必须删除配置文件中关于myaccount1 的所有信息。我刚才在这个文件中有:
Host bitbucket.org - myaccount2
User git
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/myaccount2
这样就可以了,我可以正常访问myaccount2了
如何正确配置此配置文件以保持我对这 2 个帐户的访问权限?
非常感谢你们!
您的配置文件在 Host
中具有相同的名称:"bitbucket.org"。
您需要为每一个起一个不同的名称,然后相应地调整您的 git 遥控器 url。 例如:
Host bitbucket.org
User git
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/myaccount1
Host othername
User git
Hostname bitbucket.org
PreferredAuthentications publickey
IdentityFile ~/.ssh/myaccount2
然后:
git clone git@othername/whatever.git
将从 myaccount2
更多信息here