【问题标题】:git "Host key verification failed" despite following instructions 100% [duplicate]git“主机密钥验证失败”尽管遵循说明 100% [重复]
【发布时间】:2020-11-19 17:37:00
【问题描述】:

我收到了Host key verification failed. 错误,尽管关注了GitHub's Tutorial 关于如何创建和添加新的 SSH 密钥的方法。这可能是一个本地问题,因为我在使用 GitHub Enterprise 的大学 git 中遇到了同样的错误。

我会以GitHub为例,但过程是一样的:

user@hostname:~$ ssh-keygen -t ed25519 -C "user@redacted.com"
Generating public/private ed25519 key pair.
Enter file in which to save the key (/home/user/.ssh/id_ed25519): 
Enter passphrase (empty for no passphrase): 
Enter same passphrase again: 
Your identification has been saved in /home/user/.ssh/id_ed25519
Your public key has been saved in /home/user/.ssh/id_ed25519.pub
The key fingerprint is:
[redacted] user@redacted.com
The key's randomart image is:
+--[ED25519 256]--+
|    o.           |
| + +  .  .       |
|o O o Q.+        |
|.* B +.o .       |
|o & =.o X        |
| * E o..         |
|  B X.+          |
| o =o=           |
|  ++oo.          |
+----[SHA256]-----+
user@hostname:~$ eval "$(ssh-agent -s)"
Agent pid 5220
user@hostname:~$ ssh-add ~/.ssh/id_ed25519
Identity added: /home/user/.ssh/id_ed25519 (user@redacted.com)

然后我将公钥添加到我的 GitHub 帐户。首先我使用xclip复制公钥文件的内容:

user@hostname:~$ sudo apt-get install xclip
[sudo] password for user: 
[install log for xclip. long and boring]
user@hostname:~$ xclip -selection clipboard < ~/.ssh/id_ed25519.pub 

转到 github.com > 点击右上角的图标 > 设置 > SSH 和 GPG 密钥 > 新 SSH 密钥 > 粘贴内容并为其命名 > 添加 SSH 密钥

然而……

user@hostname:~$ ssh -T git@github.com
The authenticity of host 'github.com (140.82.121.3)' can't be established.
RSA key fingerprint is SHA256:nThbg6kXUpJWGl7E1IGOCspRomTxdCARLviKw6E5SY8.
Are you sure you want to continue connecting (yes/no/[fingerprint])? 
Host key verification failed.

就像我说的,我的大学 git 也出现了同样的问题。这里有什么问题?

仅供参考,这是全新安装的 Ubuntu 20.04 LTS。

【问题讨论】:

标签: linux git github ssh


【解决方案1】:

我发现了问题。有这个选项:

Are you sure you want to continue connecting (yes/no/[fingerprint])? 

选择yes 验证了我的主机密钥。不知道为什么,如果有人能在 cmets 中对此有所了解,将不胜感激。

【讨论】:

  • 这不是在验证您的主机密钥,而是在验证 github.com 的密钥。这是为了防止机器冒充github。
猜你喜欢
  • 2012-05-30
  • 2016-10-24
  • 2016-01-21
  • 2014-01-31
  • 2016-02-02
  • 1970-01-01
  • 2018-05-15
  • 2012-11-05
  • 1970-01-01
相关资源
最近更新 更多