【发布时间】: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。
【问题讨论】: