git - 即使在添加 ssh key 后也无法克隆任何 git repo

标签 git github ssh

我正在尝试从 github 克隆一个 repo。这样做

  1. 我使用 ssh-keygen 生成了一个 ssh key 。

  2. 然后我将 ~/.ssh/id_rsa.pub 的内容添加到我在 github 帐户中的 key 。

即使在那之后我也无法克隆任何 repo。我收到以下错误:

ssh_exchange_identification: read: Operation timed out
Please make sure you have the correct access rights
and the repository exists.

在这方面,我已经翻阅了这里的一些帖子,但无法解决。

注意:即使从我的 github 帐户中删除 SSH key 后,我仍面临此错误。

编辑:当我执行“ssh -T git@github.com”时,出现同样的错误:

ssh_exchange_identification: read: Operation timed out

如建议:https://help.github.com/en/articles/error-permission-denied-publickey ,同时执行以下命令:

 1. ssh-add -l ==> The agent has no identities.
 2. ssh-add -l -E md5 ==> The agent has no identities.

最佳答案

由于以下 3 个原因之一,您会收到此错误:

  1. 当您遇到身份验证/授权问题时
  2. 当您遇到互联网访问问题时
  3. SSh 问题

执行以下操作:

首先在您的终端运行 ssh -T git@github.com 如果您在响应中看到您的 GitHub 用户名。如果没有...,您就知道您已通过正确的身份验证......

首先检查互联网访问:确保您可以通过 SSH(而非 https)克隆公共(public)存储库(任何存储库)来访问 GitHub。如果你在此处失败,则说明 SSH 或互联网连接有问题

如果此步骤通过,请尝试通过 ssh 克隆您的另一个 private 存储库。如果你失败了。您遇到身份验证问题并且您的 ssh key 错误。 (通过https重试并比较结果)

如果此步骤通过,请尝试通过 https(而非 ssh)克隆此 repo。如果你失败了。你有一个授权问题,你无权访问这个 repo

关于git - 即使在添加 ssh key 后也无法克隆任何 git repo,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58430267/

相关文章:

github - 从 github npm 注册表安装包 - 身份验证错误 401

linux - ssh 如何从 tty 接收密码?

amazon-web-services - 无法在 AWS lightail 实例中以新添加的用户身份登录

XCode 推送到 AWS CodeCommit -> 发生未知错误

Git/SmartGit 无法推送 "big"文件

github - AppVeyor 不会使用构建状态更新 GitHub 拉取请求

ubuntu - Docker,无法 SSH 到 Ubuntu 14.04 上的 rhel/centos 容器

git - 为什么公共(public)目录中的文件不会被忽略?

php - 不方便将文件升级到 git 上的远程存储库

git - 在 GitHub 上的哪里可以看到我刚刚推送的更改(以绿色和红色突出显示)?