无法建立主机的真实性

sty*_*ler 17 git ssh

我是第一次做git pull并且在git中提示无法建立主机的真实性,与我生成的私钥相比,RSA密钥指纹不正确.我只是想知道如何更新它,以便它读取正确的文件,为什么它首先读取错误的指纹?

vij*_*jay 17

我有类似的问题,这意味着远程主机是未知/不可信的.修复方法是在known_hosts文件中包含远程主机条目.

这就是我所做的:

  1. 生成(或使用现有的)RSA密钥并将其存储在<USER.HOME>/.ssh文件中.如果您使用的是eclipse,则可以使用Preferences生成RSA密钥;

    • 常规 - >网络连接 - > SSH2然后选择密钥管理.
    • 现在点击 Generate RSA Key...
    • 然后Save Private Key...在.ssh文件夹中
  2. 现在你<USER.HOME>/.ssh将包含文件; 私钥,公钥和known_hosts

  3. 与您信任的主机共享您的公钥.
  4. 打开Git Bash Promp(命令提示符)并输入以下命令.
    • ssh -vt <user>@<hostname>
    • 例如:ssh -vt git@mygithub.com
  5. 当它提示错误时...您确定要继续连接(是/否)?
  6. 说'是'
  7. 现在您的远程主机已添加到known_hosts
  8. 完成.

现在,如果您尝试将文件推送到远程,则不会看到任何错误.

  • 如果您没有自动填充known_hosts文件,请参阅https://superuser.com/a/1111974/1192848,使用`ssh-keyscan -t rsa -H gitlab.com &gt;&gt; C:\Users\USERNAME\.ssh \known_hosts`(此处为 Windows PowerShell 的示例,但相同的方法适用于 Linux)。 (3认同)

sli*_*wp2 11

将 ssh 密钥添加到 GitLab 后,当您尝试克隆存储库时,如果Enter直接按键盘,您将收到以下错误:

Cloning into 'hfe-insure-m'...
The authenticity of host 'git.zhonganinfo.com (100.112.23.182)' can't be established.
ECDSA key fingerprint is SHA256:IRLOr2bTvVB2rLgYVgyUibE+oLlZ0pUwU9wycc/5zYU.
Are you sure you want to continue connecting (yes/no/[fingerprint])? 
Host key verification failed.
fatal: Could not read from remote repository.

Please make sure you have the correct access rights
and the repository exists.
Run Code Online (Sandbox Code Playgroud)

当你看到下面这句话时,请务必输入yes,不要Enter直接按键盘。

您确定要继续连接吗(是/否/[指纹])?是的

例如

Cloning into 'hfe-insure-m'...
The authenticity of host 'git.zhonganinfo.com (100.112.23.182)' can't be established.
ECDSA key fingerprint is SHA256:IRLOr2bTvVB2rLgYVgyUibE+oLlZ0pUwU9wycc/5zYU.
Are you sure you want to continue connecting (yes/no/[fingerprint])? yes
Warning: Permanently added 'git.zhonganinfo.com,100.112.23.182' (ECDSA) to the list of known hosts.
remote: Enumerating objects: 31607, done.
remote: Counting objects: 100% (31607/31607), done.
remote: Compressing objects: 100% (10365/10365), done.
remote: Total 31607 (delta 20695), reused 31485 (delta 20604)
Receiving objects: 100% (31607/31607), 21.51 MiB | 581.00 KiB/s, done.
Resolving deltas: 100% (20695/20695), done.
Run Code Online (Sandbox Code Playgroud)