linux下sftp连接失败Host key verification failed

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

[order@Testserver ~]$ sftp appuser@121.41.12.234
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 ~]# 
©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。