【问题标题】:Bitbucket access error with two different Bitbucket accounts两个不同的 Bitbucket 帐户的 Bitbucket 访问错误
【发布时间】:2017-07-13 11:25:04
【问题描述】:

我有两个 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

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

【问题讨论】:

    标签: git ssh bitbucket bitbucket-server


    【解决方案1】:

    您必须以不同的方式命名它们:

    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

    【讨论】:

    • 不幸的是,这并不奏效:(但我用不同的方法让它工作。我会在另一个答案中解释它。
    • >>>在您的 git 存储库中使用 bitbucket1 或 bitbucket2 而不是 bitbucket.org 在哪里以及如何?在存储库的设置中,没有任何调整主机名
    • @NurbekNurjanov 在git clonegit remote set-url
    【解决方案2】:

    很可能我的两个 ssh 密钥存在冲突,我的私人帐户无法从这台机器获得对我的 Bitbucket 的任何权限。

    突然间,我想将我的办公室 ID 分配给我的个人仓库,从

    Settings > User and Group Access > User
    

    并授予该 ID 管理员权限,它运行良好。

    也许这不是优雅的方式,也不是问题的实际解决方案,但此时它可以完美运行。

    【讨论】:

      【解决方案3】:

      Bitbucket 允许使用“git”或“hg”以外的用户名通过 SSH 访问存储库。您可以在与工作相关的存储库中执行类似git remote set-url origin myawesomeusername@bitbucket.org:owner/repo.git 的操作(假设“myawesomeusername”是您的用户名,“owner/repo.git”是相关存储库的路径),或者您可以编辑 .git/config 文件在每个 repo 中将 URL 中的 git@bitbucket.org 更改为 myawesomeusername@bitbucket.org

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2016-02-18
        • 1970-01-01
        • 2015-07-02
        • 2018-02-21
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多