Bitbucket访问错误与两个不同的Bitbucket帐户

时间:2017-07-13 11:25:04

标签: git ssh bitbucket bitbucket-server

我有两个Bitbucket帐号。一个用于办公室,另一个用于个人。现在我还为这些帐户创建了两个SSH密钥并添加了密钥,但现在看来我无法访问我的个人帐户。

当我尝试git push -u origin develop时,我收到此错误:

repository access denied.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.

这是我的.ssh/config文件:

 1 Host bitbucket.org
 2        User git
 3        Hostname bitbucket.org
 4        IdentityFile ~/.ssh/id_rsa_bitbucket
 5        TCPKeepAlive yes
 6        IdentitiesOnly yes
 7
 8 Host bitbucket.org
 9        User git
 10        Hostname bitbucket.org
 11        IdentityFile ~/.ssh/id_rsa
 12        TCPKeepAlive yes
 13        IdentitiesOnly yes

第一个用于我的办公室,第二个用于我的个人帐户。我知道如何解决这个问题?

3 个答案:

答案 0 :(得分:0)

您必须以不同方式命名:

Host bitbucket1
    User git
    Hostname bitbucket.org
    IdentityFile ~/.ssh/id_rsa_bitbucket
    TCPKeepAlive yes
    IdentitiesOnly yes

Host bitbucket2
    User git
    Hostname bitbucket.org
    IdentityFile ~/.ssh/id_rsa
    TCPKeepAlive yes
    IdentitiesOnly yes

在您的git存储库中使用bitbucket1bitbucket2代替bitbucket.org

答案 1 :(得分:0)

很可能与我的两个ssh密钥存在冲突,我的私人帐户无法获得此机器对我的Bitbucket的任何许可。

突然之间我想

中将我的办公室ID分配给我的个人仓库
Settings > User and Group Access > User

并授予该ID管理员权限,并且完美无缺。

也许这不是优雅的方式而不是问题的实际解决方案,但它在这一刻完美运作。

答案 2 :(得分:0)

Bitbucket允许除“git”或“hg”之外的用户名来访问repos。您可以在工作相关的回购中执行类似git remote set-url origin myawesomeusername@bitbucket.org:owner/repo.git的操作(假设“myawesomeusername”是您的用户名,“owner / repo.git”是相关回购的路径),或者您可以编辑.git /每个仓库中的配置文件都会将网址中的git@bitbucket.org更改为myawesomeusername@bitbucket.org

相关问题