【问题标题】:can't pull changes from github - Permission denied (publickey). fatal: Could not read from remote repository无法从 github 拉取更改 - 权限被拒绝(公钥)。致命:无法从远程存储库中读取
【发布时间】:2015-01-22 21:42:24
【问题描述】:

我试图将项目从 github 拉到我的本地存储库。

我生成了所有必要的 ssh 密钥。我克隆了这个项目。但是当我试图提取更改时,我发现了:

$ git pull
The authenticity of host 'github.com (192.30.252.129)' can't be established.
RSA key fingerprint is 16:27:ac:a5:76:28:2d:36:63:1b:56:4d:eb:df:a6:48.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'github.com,192.30.252.129' (RSA) to the list of know
n hosts.
Permission denied (publickey).
fatal: Could not read from remote repository.

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

这里是.ssh的内容:

C:\Users\nlel.ssh 目录

15.01.2014  13:35    <DIR>          .
15.01.2014  13:35    <DIR>          ..
09.01.2014  15:24             1 675 github_rsa
09.01.2014  15:24               391 github_rsa.pub
09.01.2014  13:08             1 751 id_rsa
09.01.2014  13:08               405 id_rsa.pub
15.01.2014  13:36               803 known_hosts
               5 File(s)          5 025 bytes
               2 Dir(s)  59 142 991 872 bytes free

它们出现在 github 帐户上。我克隆了项目ok。

解决方案:

我重新创建了我的密钥。并使用关键短语再次生成它们。
我从 pc 和 github 中删除了旧密钥并添加了新密钥。

现在一切正常。棘手的一点是这个 repo 是私有的。

- 为什么会这样?
- 如何解决这个问题?

【问题讨论】:

  • 你用来克隆的命令是什么,克隆后你有没有对键进行任何更改?
  • 好的,我已将您的结论包含在答案中以提高知名度。

标签: git github ssh pull


【解决方案1】:

ssh 只会寻找%HOME%\.ssh\id_rsa(.pub)

如果您希望 ssh 选择一组 不同 键,您需要在 %HOME\.ssh\config 文件中声明它们(我在您的目录中没有看到)。

config 文件将包含以下内容:

Host github
  HostName github.com
  User git
  IdentityFile C:\path\to\.ssh\github_rsa
  IdentitiesOnly yes

重命名您的“origin”遥控器的网址:

cd /path/to/my/repo
git remote set-url origin github:yourName/YourRepo.git

这是推送(写入)您拥有的 GitHub 存储库所必需的。
您根本不需要 ssh 密钥来从 public 存储库中提取(读取)。


OP nazar-art 的情况下,密钥可能不是正确的,重新创建这些就足够了:

我重新创建了我的密钥。并使用关键短语再次生成它们。
我从 pc 和 github 中删除了旧密钥并添加了新密钥。

【讨论】:

猜你喜欢
  • 2016-11-28
  • 2014-08-30
  • 2018-08-24
  • 2017-07-31
  • 1970-01-01
  • 1970-01-01
  • 2013-07-11
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多