代码之家  ›  专栏  ›  技术社区  ›  Johnmark Wachira

权限被拒绝(公钥)无法从远程存储库读取

  •  1
  • Johnmark Wachira  · 技术社区  · 7 年前

    我正在尝试将我的站点推送到digital ocean上的服务器,但我一直遇到这个错误。

    local-machine@my-server-address: Permission denied (publickey).
    fatal: Could not read from remote repository.
    
    Please make sure you have the correct access rights
    and the repository exists.
    

    我已经设置了ssh密钥并在服务器上使用了它。我可以通过ssh访问该站点,但当我尝试使用git remote时,访问被拒绝。我已经仔细检查了我的存储库。

    4 回复  |  直到 7 年前
        1
  •  1
  •   antzshrek    7 年前

    有一点很明显,那就是 SSH密钥 ,发生的事情是数字海洋无法验证您的身份。“因此,要么您没有使用SSH密钥进行设置,因为您的计算机上没有设置SSH密钥,要么您的密钥与您的digital ocean帐户没有关联。

    您可能希望尝试的另一个选项是使用 HTTPS URL 而不是SSH URL,以避免处理SSH密钥。

    您可能需要进一步阅读git Error: Permission denied (publickey)

        2
  •  1
  •   Johnmark Wachira    7 年前

    谢谢大家的帮助。我解决了这个问题。我添加了一个遥控器,但没有指定用户。

    git remote add production ssh://my-server-address/var/repo/site.git
    

    而不是

    git remote add production ssh://root@my-server-address/var/repo/site.git 
    
        3
  •  0
  •   Ray Koren    6 年前

    检查的输出 git remote -v . 确保您指向正确的回购。

        4
  •  -2
  •   Adis    6 年前

    答案是针对Github用户的。根据url: https://help.github.com/en/articles/generating-a-new-ssh-key-and-adding-it-to-the-ssh-agent

    将一行添加到 ~/.ssh/config :

    Host *
      User git     <-------this line.
      AddKeysToAgent yes
      UseKeychain yes
      IdentityFile ~/.ssh/id_rsa