ssh登陆提示"Host key verification failed."的解决方法


ssh登陆提示"Host key verification failed."的解决方法
 
1、在某些情况下,如同个IP地址,不同端口连到不同linux机子上时,可能有此提示
 
2、报错信息如下:
    @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
    @    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 the RSA host key has just been changed.
    The fingerprint for the RSA key sent by the remote host is
    23:00:20:83:de:02:95:f1:e3:34:be:57:3f:cf:2c:e7.
    Please contact your system administrator.
    Add correct host key in /home/xahria/.ssh/known_hosts to get rid of this message.
    Offending key in /home/xahria/.ssh/known_hosts:8
    RSA host key for localhost has changed and you have requested strict checking.
    Host key verification failed.
 
 
3、用OpenSSH的人都知ssh会把你每个你访问过计算机的公钥(public key)都记录在~/.ssh/known_hosts。当下次访问相同计算机时,OpenSSH会核对公钥。如果公钥不同,OpenSSH会发出警告,避免你受到DNS Hijack之类的攻击。
 
 
4、在.ssh/config(或者/etc/ssh/ssh_config)中的配置项StrictHostKeyChecking:
    默认是ask:如果连接和key不匹配,给出提示,并拒绝登录,默认是被注释掉的。
    yes:如果连接与key不匹配,就拒绝连接,不会提示。
    no:如果连接的key在本地不存在,那么就自动添加到文件中(默认是known_hosts),并且给出一个警告,可以连接成功。
 
 
5、为了防止出现警告提示,且解决同个IP不同端口连接,可选择性地降低安全性,如下配置:
    vi /etc/ssh/ssh_config 
 
 
    StrictHostKeyChecking no
    UserKnownHostsFile /dev/null #将knownhostfile设为/dev/null,就不保存在known_hosts中了

相关内容

    暂无相关文章