linux下sftp连接失败Host key verification failed

问题描述:
linux重装系统后,通过另一台服务器连接此服务器报错

[order@Testserver ~]$ sftp [email protected]
Connecting to 121.41.12.234...
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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
d1:d5:03:c2:1a:3b:de:3f:9b:a5:56:34:44:e4:8a:63.
Please contact your system administrator.
Add correct host key in /app/order/.ssh/known_hosts to get rid of this message.
Offending key in /app/order/.ssh/known_hosts:14
RSA host key for 121.41.12.234 has changed and you have requested strict checking.
Host key verification failed.
Couldn't read packet: Connection reset by peer

问题原因:
RSA host key for 121.41.12.234 has changed and you have requested strict checking.
Host key verification failed.
重装系统后修改了密码,而ssh会把每次访问过的计算机的公钥都保存在~/.ssh/known_hosts文件中,当下次访问同样的计算机时,openssh会核对公钥,如果公钥不对,会发出警告;
解决问题:
1、打开~/.ssh/known_hosts文件,然后找到对应ip的记录,删除;
2、ssh-keygen -R +ip ;

[root@Testserver ~]# ssh-keygen -R 121.41.12.234
/root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old
[root@Testserver ~]# 

你可能感兴趣的:(linux下sftp连接失败Host key verification failed)