Linux 不能;git pull“是什么主机密钥验证失败

Linux 不能;git pull“是什么主机密钥验证失败,linux,git,gitlab,ssh-keys,Linux,Git,Gitlab,Ssh Keys,我拥有对生产服务器的root访问权限,我想在服务器上部署最新版本的git,但当我在要更新的文件夹上“git pull”时遇到以下错误 我浏览了一下,但找不到关于该怎么办的明确答案 暂存服务器运行在同一台机器上,但只是在不同的文件夹中,当我在该文件夹上拉时,一切都会正常进行 我对Linux不是很有经验,所以请帮助我清楚地回答如何修复:-) 否则我可以得到我需要的任何东西 p、 美国。 这在过去是有效的,所以我假设它与SSH密钥有关 错误: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@

我拥有对生产服务器的root访问权限,我想在服务器上部署最新版本的git,但当我在要更新的文件夹上“git pull”时遇到以下错误

我浏览了一下,但找不到关于该怎么办的明确答案

暂存服务器运行在同一台机器上,但只是在不同的文件夹中,当我在该文件夹上拉时,一切都会正常进行

我对Linux不是很有经验,所以请帮助我清楚地回答如何修复:-)

否则我可以得到我需要的任何东西

p、 美国。 这在过去是有效的,所以我假设它与SSH密钥有关

错误:

@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@       WARNING: POSSIBLE DNS SPOOFING DETECTED!          @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
The ECDSA host key for www.site.org has changed,
and the key for the corresponding IP address x.x.x.x
is unknown. This could either mean that
DNS SPOOFING is happening or the IP address for the host
and its host key have changed at the same time.
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!     @
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
Someone could be eavesdropping on you right now (man-in-the-middle attack)!
It is also possible that a host key has just been changed.
The fingerprint for the ECDSA key sent by the remote host is
*************
Please contact your system administrator.
Add correct host key in /root/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /root/.ssh/known_hosts:1
  remove with: ssh-keygen -f "/root/.ssh/known_hosts" -R gitlab.site.org
ECDSA host key for gitlab.site.org has changed and you have requested strict checking.
Host key verification failed.

在日志中可以看到以下文本:

(...) Please contact your system administrator. Add correct host key in /root/.ssh/known_hosts to get rid of this message. Offending ECDSA key in /root/.ssh/known_hosts:1 remove with: ssh-keygen -f "/root/.ssh/known_hosts" -R gitlab.site.org ECDSA host key for gitlab.site.org has changed and you have requested strict checking. Host key verification failed.
窗口:

  • 转到
    /Users/Abhilash/.ssh/known_hosts
    ,删除其中的内容并保存
  • Linux/Mac:

  • 转到
    ~/.ssh/
  • nano-u主机
  • 删除内部内容并保存
    ctrl+O
  • 注意:
    再次按下时将提示您保存密钥。

    如果要永久删除此消息,您可以编辑ssh配置文件(
    ~/.ssh/config
    )以包括:

    Host {YOUR HOST HERE}
     StrictHostKeyChecking no
     UserKnownHostsFile /dev/null
    

    在遵循这些步骤之后,我也遇到了同样的问题,这对我来说很有效

    对于macOS:

    Step 1: Go to Folder or use command+shift+g
    Step 2: type "~/.ssh/"
    Step 3: Open "known_hosts" file and Remove all the content
    Step 4: Now Open terminal and pull from another branch, It will ask for password give your system password.
    

    它肯定会起作用。

    所有其他答案都会带来安全风险

    出现此错误是因为在
    已知的\u hosts
    文件中有一条记录,其中指出服务器应该具有特定的ssh密钥。但是,当您尝试连接时,服务器发送了一个不同的ssh密钥,该密钥与您的
    known_hosts
    文件中的不匹配。您的特定错误消息显示:

    Offending ECDSA key in /root/.ssh/known_hosts:1
    
    The authenticity of host 'gitlab.com (172.65.251.78)' can't be established.
    ECDSA key fingerprint is SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw.
    Are you sure you want to continue connecting (yes/no/[fingerprint])?
    
    这意味着
    known_hosts
    文件中的第一行与远程服务器发送的内容不同

    解决此问题的安全方法如下所示:

  • 从可靠的来源中找出正确的密钥指纹。e、 在这里你可以找到和的正确指纹。(如果您的组织自行托管GitLab,则需要与管理员交谈以获取ssh密钥指纹。)
  • 检查
    known_hosts
    文件中的现有指纹是否正确。
    您可以运行
    ssh-keygen-lf~/.ssh/known_hosts
    (或者在您的情况下运行
    /root/.ssh/known_hosts
    )从
    known_hosts
    文件生成SHA256指纹。您的错误消息表明问题出在第一个键上。在GitHub或GitLab上找到等效的SHA256指纹,并检查其是否完全匹配。
    The authenticity of host 'gitlab.com (172.65.251.78)' can't be established.
    ECDSA key fingerprint is SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw.
    Are you sure you want to continue connecting (yes/no/[fingerprint])?
    
    e、 g.以下是上述命令的输出:
    256 SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw gitlab.com (ECDSA)
    
    这是网站上的ECDSA SHA256指纹:
  • 如果从已知Noths//Cord>中的现有指纹与OR网站的官方指纹匹配,则<代码> SSH 检测到中间人(MITM)攻击。strong>停止。不要连接到服务器。尝试从其他internet连接进行连接。与管理员交谈
  • 如果已知\u主机中的现有指纹与官方指纹不匹配,则说明您之前受到了MitM攻击,或者承载GitLab的服务器更改了其ssh密钥。您可以从
    已知主机
    文件中删除指纹。(注意:仅删除引起问题的特定指纹。)下次连接到GitLab时,系统将提示您将新指纹添加到
    已知\u主机
    文件中。
    The authenticity of host 'gitlab.com (172.65.251.78)' can't be established.
    ECDSA key fingerprint is SHA256:HbW3g8zUjNSksFbqTiUWPWg2Bq1x8xdGUrliXFzSnUw.
    Are you sure you want to continue connecting (yes/no/[fingerprint])?
    
    再次检查指纹是否与或网站上显示的指纹匹配,然后相应地键入
    yes
    no

  • +1解决这个问题的最佳方法。另一种方法是删除
    ~/.ssh/known_hosts
    中gitlab.site.org的条目@Richard,也试着调查为什么密钥发生了变化,因为大多数时候它们都不应该改变。这里所有的答案都是让用户面临安全风险。在更新
    ~/.ssh/known_hosts
    之前,您应该确保添加的密钥是合法的。Github在这里列出了:Gitlab的:@anOkCoder,但在本例中,它不是关于添加,而是关于删除一个键。也许我当时误解了这个命令的意图。我的理解是,如果删除主机的密钥,则在尝试新的ssh时,将提示您为该主机添加新密钥。在这种情况下,当用户重新运行git pull时,就会削弱整个过程的安全性。支票在那里是有原因的。谢谢你节省了我的时间。