一、错误描述

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
[root@slave1 ~]# ssh-copy-id master.hadoop
/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"
/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/bin/ssh-copy-id: ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ERROR: @ WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED! @
ERROR: @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
ERROR: IT IS POSSIBLE THAT SOMEONE IS DOING SOMETHING NASTY!
ERROR: Someone could be eavesdropping on you right now (man-in-the-middle attack)!
ERROR: It is also possible that a host key has just been changed.
ERROR: The fingerprint for the ECDSA key sent by the remote host is
ERROR: SHA256:rUXoAX6rSbaGn5IIv6pdcrm9eaajEdwZcrRzVlioUaU.
ERROR: Please contact your system administrator.
ERROR: Add correct host key in /root/.ssh/known_hosts to get rid of this message.
ERROR: Offending ECDSA key in /root/.ssh/known_hosts:1
ERROR: ECDSA host key for master.hadoop has changed and you have requested strict checking.
ERROR: Host key verification failed.

二、解决方案

1
本地上次存储的 known_hosts 文件进行更新,我们的目标主机发生改变,需要进行手动更新一下,再重新连接一一下就可以了。

输入以下指令:(对本地的 known_hosts 文件进行更新)

1
ssh-keygen -R XXX(目标主机ip地址)

按照我的例子(ip:192.168.1.1),会返回以下信息:

1
2
3
4
5
6
[root@slave1 .ssh]# ssh-keygen -R 192.168.1.1

# Host 192.168.1.1 found: line 1

/root/.ssh/known_hosts updated.
Original contents retained as /root/.ssh/known_hosts.old

重新尝试连接:

输入yes,按下回车,成功连接。