做免密登录传输文件的时候报错:ERROR: Host key verification failed.:解决方法
报错信息:
在做好公钥以后,准备进行传输到另一台机器的时候,发生了报错。
报错原因:
1、在CSDN上面找到了问题的根源,是因为/root/.ssh/known_hosts文件里面有传输错误的记录。
2、没有记录的都可以正常传输,至此才找到问题的解决办法。
解决方法:
1、切换到/root/.ssh/:
[root@k8s-master01 ~]# cd /root/.ssh/
[root@k8s-master01 .ssh]# ll
total 16
-rw------- 1 root root 1195 Apr 6 03:56 authorized_keys
-rw-------. 1 root root 1675 Apr 6 03:56 id_rsa
-rw-r--r--. 1 root root 399 Apr 6 03:56 id_rsa.pub
-rw-r--r-- 1 root root 1570 Apr 6 03:56 known_hosts
2、找到known_hosts文件,进入:
[root@k8s-master01 .ssh]# vim known_hosts
k8s-master02 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJIgNyJq9mJps72paESq6nfRVbcs0cSaD/AGeWPTCSyl2IAsfkbvwZe7L5hdBL76NylspcxPnHhq53tspRtNjy4=
k8s-master03 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMLNuBDmO6ZObI+pkUtagbHwN5inDhST+LaKMhpxtplB/TV+Ce3puZbrsl8vGRaM7rEEq6mFziHfScGw2xqifSg=
192.168.1.5 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBN4l62XeL0DIoZwhpg6xlKQ5ZWpir2AQo8HwI4YGw26Dlsis5oNw0/xb8jIBj8o8dGSrTh3fnexq6d/LgZm7DnU=
192.168.1.6 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBDaC79YOclqgKv361OPWWoWlEhkm5aKjGfRQam66ZxLRDsZC8nJWbvivfDXQnfNRmyC3wBnOI1nbsJ8sTtsxLIQ=
192.168.1.3 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBJIgNyJq9mJps72paESq6nfRVbcs0cSaD/AGeWPTCSyl2IAsfkbvwZe7L5hdBL76NylspcxPnHhq53tspRtNjy4=
k8s-master01,192.168.1.2 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBCxJMmlc9ZI7uSB31HrYEyBsr3NjJvXF6Ym3JPv2dS9//7Aj+rbDexnTpce1DQ94v8TfTSQ6+vP6lW3scnFcqsI=
192.168.1.4 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBMLNuBDmO6ZObI+pkUtagbHwN5inDhST+LaKMhpxtplB/TV+Ce3puZbrsl8vGRaM7rEEq6mFziHfScGw2xqifSg=
k8s-node01 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBN4l62XeL0DIoZwhpg6xlKQ5ZWpir2AQo8HwI4YGw26Dlsis5oNw0/xb8jIBj8o8dGSrTh3fnexq6d/LgZm7DnU=
k8s-node02 ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBDaC79YOclqgKv361OPWWoWlEhkm5aKjGfRQam66ZxLRDsZC8nJWbvivfDXQnfNRmyC3wBnOI1nbsJ8sTtsxLIQ=
3、哪台机器传输的时候报错就删哪台机器的记录,最后保存退出,然后再次尝试,即可。