标签: known_hosts

  • 如何解决无法通过SSH或SFTP连接服务器问题

    错误类型:
    其他错误
    错误名称:
    无法通过SSH或SFTP连接服务器
    英文名称:
    Host key verification failed
    错误描述:
    这通常是因为IP地址或SSH密钥指纹已更改(通常是由于服务器更新),而旧的仍存储在您的known_hosts文件中,该文件用于SSH和SFTP连接。

    如何解决无法通过SSH或SFTP连接服务器问题

    通过SSH或SFTP连接时遇到问题?如果您收到如下所示的错误,这通常是因为IP地址或SSH密钥指纹已更改(通常是由于服务器更新),而旧的仍存储在您的known_hosts文件中,该文件用于SSH和SFTP连接。

    [user@hostname ~]$ ssh root@user
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @ 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 RSA key sent by the remote host is
    xx:xx:xx.
    Please contact your system administrator.
    Add correct host key in /home/hostname /.ssh/known_hosts to get rid of this message.
    Offending RSA key in /var/lib/sss/pubconf/known_hosts:4
    RSA host key for user has changed and you have requested strict checking.
    Host key verification failed.
    [user@hostname ~]$ ssh root@user
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @ 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 RSA key sent by the remote host is
    xx:xx:xx.
    Please contact your system administrator.
    Add correct host key in /home/hostname /.ssh/known_hosts to get rid of this message.
    Offending RSA key in /var/lib/sss/pubconf/known_hosts:4
    RSA host key for user has changed and you have requested strict checking.
    Host key verification failed.
    [user@hostname ~]$ ssh root@user
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @ 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 RSA key sent by the remote host is
    xx:xx:xx.
    Please contact your system administrator.
    Add correct host key in /home/hostname /.ssh/known_hosts to get rid of this message.
    Offending RSA key in /var/lib/sss/pubconf/known_hosts:4
    RSA host key for user has changed and you have requested strict checking.
    Host key verification failed.

    如果您在连接时遇到问题,请首先确保您使用的是正确的密码。

    如果仍有问题,请按照以下说明从known_hosts文件中删除条目。

    Mac或Linux

    1.打开终端并使用nano文本编辑器编辑以下文件。

    nano ~/.ssh/known_hosts
    nano ~/.ssh/known_hosts
    nano ~/.ssh/known_hosts

    2.删除所有以您的服务器IP地址开头的条目。

    3.然后保存文档 (Ctrl+x)。

    Windows

    如果您使用的是Windows,它也有一个类似的known_hosts文件,但凭据和IP存储在注册表中。

    1.从开始菜单启动regedit。下面的示例使用的是Windows 10。

     

    Windows注册表编辑器

    Windows注册表编辑器

     

    2.浏览到以下目录:HKEY_CURRENT_USERSoftWareSimonTathamPuTTYSshHostKeys

     

    SSH主机密钥

    SSH主机密钥

     

    3.删除所有以您的服务器IP地址结尾的条目。