背景:重装Linux之后,在Windows上使用CMD窗口使用ssh命令连接报错;
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ @ 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 SHA256:tVNIZhX3kfXfgemLzcBSGhdQoDYtwNlm0iQ1HhliGVs. Please contact your system administrator. Add correct host key in C:\\Users\\shiji/.ssh/known_hosts to get rid of this message. Offending ECDSA key in C:\\Users\\shiji/.ssh/known_hosts:1 ECDSA host key for hadoop100 has changed and you have requested strict checking. Host key verification failed.
解决方案
直接到windows /Users/watsy/.ssh/ 下删除 known_hosts即可
什么是known_hosts文件
A通过ssh首次连接到B,B会将公钥1(host key)传递给A,A将公钥1存入known_hosts文件中,以后A再连接B时,B依然会传递给A一个公钥2,OpenSSH会核对公钥,通过对比公钥1与公钥2 是否相同来进行简单的验证,如果公钥不同,OpenSSH会发出警告, 避免你受到DNS Hijack之类的攻击。。
打开known_hosts文件
1、Linux环境
vi ~/.ssh/known_hosts 或 vi /root/.ssh/known_hosts
2、Windows环境
打开资源管理器,在地址栏输入 %USERPROFILE%\ssh 或 %USERPROFILE%\.ssh 回车