Github验证但不允许代码推送

时间:2015-11-01 21:31:23

标签: git github

我是“项目”回购的所有者,但不知怎的,我无法推动它。

user@none ~/rails_projects/project $ git remote -v
origin  git@github.com:user/project.git (fetch)
origin  git@github.com:user/project.git (push)

以下是身份验证检查:

user@none ~/rails_projects/project $ ssh -T git@github.com
Hi user/project! You've successfully authenticated, but GitHub does not provide shell access.

推送尝试:

user@none ~/rails_projects/project $ git push origin qa
ERROR: The key you are authenticating with has been marked as read only.
fatal: Could not read from remote repository.

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

知道如何修复此错误吗?

4 个答案:

答案 0 :(得分:8)

您可能拥有多个SSH密钥,并且显示的密钥是存储库的部署密钥,而不是具有写入权限的帐户密钥之一。有两种方法可以解决这个问题:

  1. 从SSH代理中删除所有密钥,然后重新添加正确的帐户密钥。

    ssh-add -D
    ssh-add /path/to/correct/key
    
  2. 使用HTTPS instead of SSH。您可以通过changing the remote URL origin 轻松完成此操作,以使用HTTPS方案而不是SSH。

  3. 除非您只是简单地提供错误的凭据,否则其中一个或另一个应该有效。

答案 1 :(得分:4)

错误:

  

错误:您要进行身份验证的密钥已被标记为只读。

可能意味着你:

  • 您尝试使用与其他存储库关联的密钥(例如部署密钥)来尝试推送回购,因此check由:

    $ ssh -i ~/.ssh/id_rsa git@github.com
    Hi user/project! You've successfully authenticated, but GitHub does not provide shell access.
    

    并比较user/project,如果它与您要推送的存储库相同。

  • 您的密钥已被锁定(例如,它已长时间未使用),因此您必须通过完成对GitHub用户现有ssh密钥的审核来重新确认密钥个人资料(/settings/ssh),

  • 您同时使用多个密钥,请检查:ssh-add -l(如果是,请将其删除并重新添加正确的密钥)。

所以:

  

请确保您拥有正确的访问权限并且存储库已存在。

通过以下简单步骤:

  1. 通过以下方式注意您的RSA指纹:

    $ ssh-add -l
    2048 xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx:xx (stdin) (RSA)
    
  2. 然后在GitHub上查看它是否已添加到您的帐户或存储库中:

    • 帐户,请查看:/settings/ssh(SSH密钥),

      • 如果遗失,请添加,
      • 如果密钥已在使用,请找到使用它的其他代理商(见下文),然后删除并重新添加到您的帐户中
    • 针对特定存储库,请查看::name/:repo/settings/keys(部署密钥),

    • 如果您不是存储库所有者,请检查您是否在正确的群组中(使用推送访问权限)。
  3. 或者使用&添加新密钥troubleshoot common SSH Problemscontact GitHub support,因为他们可以出于某种原因撤销它(例如通过公开披露它)。

答案 2 :(得分:1)

如果您有一个存储库的部署密钥,在创建密钥时没有写访问权限并且您尝试推送到该存储库,也会发生这种情况。创建密钥时,不要忘记选中“允许写入访问”复选框。

答案 3 :(得分:1)

这是我犯的一个愚蠢的错误,解决方法很简单。 只需删除部署密钥,再次添加相同的私钥或新的私钥,这一次,只需 don't forget to mark the "Allow write access" option

Just don't forget to mark this when adding a new SSH key in github