使用scp传输文件 Host key verification failed.解决

在用scp传输文件时,看到如下报错信息:

ysgz@ysgz:~/Desktop$ scp check.sh [email protected]:/tools
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@    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:KcPDWuynzibxrbck/KdtmHw0/HBdw8oG5ujdex5mync.
Please contact your system administrator.
Add correct host key in /home/ysgz/.ssh/known_hosts to get rid of this message.
Offending ECDSA key in /home/ysgz/.ssh/known_hosts:1
  remove with:
  ssh-keygen -f "/home/ysgz/.ssh/known_hosts" -R "192.168.3.6"
ECDSA host key for 192.168.3.6 has changed and you have requested strict checking.
Host key verification failed.
lost connection

这不是什么大问题,只需要按照提示信息,删除~/.ssh/known_hosts即可,

rm -rf ~/.ssh/known_hosts

删了再次scp的时候可以自己生成 

ysgz@ysgz:~$ cat ~/.ssh/known_hosts 
|1|EezdVKDyqBt9EShZhBNJq2dJmU4=|81s8jFd7R2QU9Dz9jaQ6A6qZ6Fo= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLl6estMq2cx9XUnKm65PKsGqOdigBPBcEahbzQ0ab2wpFGlw9+S1Qfm02Oy0JTaDy70DcrQ+yJbHM5A6XudZmA=
|1|VzzbXfNPnH2eFg/d/bEsjR5gmvU=|/TAy/oufqKAOcVu2tEGAUmqt+KE= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLl6estMq2cx9XUnKm65PKsGqOdigBPBcEahbzQ0ab2wpFGlw9+S1Qfm02Oy0JTaDy70DcrQ+yJbHM5A6XudZmA=
ysgz@ysgz:~$ rm -rf ~/.ssh/known_hosts 
ysgz@ysgz:~$ cat ~/.ssh/known_hosts
cat: /home/ysgz/.ssh/known_hosts: 没有那个文件或目录
ysgz@ysgz:~$ 
ysgz@ysgz:~$ scp 1.txt [email protected]:/tools
The authenticity of host '192.168.3.6 (192.168.3.6)' can't be established.
ECDSA key fingerprint is SHA256:KcPDWuynzibxrbck/KdtmHw0/HBdw8oG5ujdex5mync.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '192.168.3.6' (ECDSA) to the list of known hosts.
[email protected]'s password: 
1.txt                                                                    100%    3     3.3KB/s   00:00    
ysgz@ysgz:~$ cat ~/.ssh/known_hosts
|1|BVs3RapB4hLRUwZooipNPHnC+jU=|BB1hY6f9JFxmVixVnrZGpmaXbi8= ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBLl6estMq2cx9XUnKm65PKsGqOdigBPBcEahbzQ0ab2wpFGlw9+S1Qfm02Oy0JTaDy70DcrQ+yJbHM5A6XudZmA=
ysgz@ysgz:~$ 

我出现这个的原因,是不小心把“@”错敲成了“:”

ysgz@ysgz:~$ scp check.sh ysgz:192.168.3.6:/tools
The authenticity of host 'ysgz (127.0.1.1)' can't be established.
ECDSA key fingerprint is SHA256:KcPDWuynzibxrbck/KdtmHw0/HBdw8oG5ujdex5mync.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'ysgz' (ECDSA) to the list of known hosts.
ysgz@ysgz's password: 
Permission denied, please try again.
ysgz@ysgz's password: 
check.sh: No such file or directory

你可能感兴趣的:(Linux,scp,ssh)