【问题标题】:Permission denied (publickey) when using SSH with Git将 SSH 与 Git 一起使用时权限被拒绝(公钥)
【发布时间】:2020-01-25 15:20:36
【问题描述】:

我正在将 Windows 与 Git(Github 和本地 GitLab 实例)一起使用,但我无法从任一服务克隆。

以下是我在 Github 上公开回购时遇到的错误。

Cloning into 'xxx-java'...
The authenticity of host 'github.com (140.82.118.3)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpxwxE1IGOCspscxdCARLsdKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'github.com,140.82.118.3' (RSA) to the list of known hosts.
git@github.com: Permission denied (publickey).
fatal: Could not read from remote repository.

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

在我看来,我的 SSH 密钥有问题,但我完全按照 Gitlab documentation. 中的说明创建了它们

我错过了什么? (需要注意的是,通过 HTTPS 克隆可以正常工作)。

【问题讨论】:

标签: git ssh


【解决方案1】:

检查您是否已将公钥正确复制到 GitHub 帐户。公钥通常以“ssh-rsa”和一个编码密钥开头。同样的事情发生在我身上,原因是我没有正确复制公钥。

【讨论】:

  • 是的,复制正确,我验证了好几次。
  • 还要验证生成密钥时使用的邮箱是否可以访问github仓库
【解决方案2】:

首先,我建议检查一些标准的东西,例如:

  1. 以系统中的正确用户身份登录,
  2. 在系统中的正确位置拥有正确的私钥,
  3. 尝试使用正确的用户名、主机名和端口进行连接,
  4. 在正确的位置(并为正确的用户)拥有公钥 在外部服务器中,
  5. 在您的计算机上重新启动了 ssh 服务:

或确保 https 也。

ssh -vT git@github.com

【讨论】:

  • ssh -vT git@github.com 实际上以debug1: No more authentication methods to try. git@github.com: Permission denied (publickey). 失败
猜你喜欢
  • 2020-07-02
  • 1970-01-01
  • 2011-11-25
  • 1970-01-01
  • 1970-01-01
  • 2019-11-24
  • 2014-11-08
  • 2019-03-11
  • 1970-01-01
相关资源
最近更新 更多