SCP: WARNING: REMOTE HOST IDENTIFICATION HAS CHANGED!

今天通过 scp 拷文件时出现以下ERROR, 根据提示信息可能是出于安全方面原因,密钥发生改变。

报错信息

连接丢失,报错信息如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
[postgres@skytf](mailto:postgres@skytf)-> scp *.ddl [postgres@192.168.1.35:/pgdata/uims_ppa/1921/data05/pg_bakcup](mailto:postgres@192.168.1.35:/pgdata/uims_ppa/1921/data05/pg_bakcup)  
@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@
@ 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
d3:94:17:c4:69:6f:28:5e:8e:a9:88:0d:88:f4:5e:df.
Please contact your system administrator.
Add correct host key in /home/postgres/.ssh/known_hosts to get rid of this message.
Offending key in /home/postgres/.ssh/known_hosts:2
RSA host key for 192.168.1.35 has changed and you have requested strict checking.
Host key verification failed.
lost connection

解决方法

解决方法比较简单,只要删除ssh client 端文件 ~/.ssh/known_hosts 中对应记录信息即可。

1
2
3
4
5
6
7
8
9
10
[postgres@skytf](mailto:postgres@skytf)-> cd ~/.ssh  
[postgres@skytf](mailto:postgres@skytf)-> pwd
/home/postgres/.ssh
[postgres@skytf](mailto:postgres@skytf)-> ll
total 20K
-r-------- 1 postgres postgres 668 Jul 4 2011 id_dsa
-r-------- 1 postgres postgres 642 Jul 4 2011 id_dsa.pub
-r-------- 1 postgres postgres 1.7K Jul 4 2011 id_rsa
-r-------- 1 postgres postgres 434 Jul 4 2011 id_rsa.pub
-rw------- 1 postgres postgres 1.6K Mar 26 13:44 known_hosts

修改文件 known_hosts,删除对应IP记录信息即可。

1
2
3
4
5
192.168.1.35 ssh-rsa AAAAB3NzaC1yc2EAAAABIwAAAQEA2Xhr9XQXTLXp+61nQRelAsms1SDbZH31QX  
u+wK/fUNCGVgxXoqwIq/tf8Cg+MgJlVRvLb3HHGK5nTGFnda/b49ITVi/TCOwEurzTIjMRm+RpDOzMWEvZN
SeNIOixcExi52D9Q3U1zebMG1U5ecxmzkvZMnwdOQpFvf9d1bGPbRY3+cn2i9yZr/ccJqTms+QMImV0VK35
QOFIxHuDTLltkowewd8AuIwCytT+k7UqP7Pe+NYzWK5bReKJuvrQheGjmEpVD3uXoqyMRfl/SuDnUXFWIyP
yfFO9NhHFT9NwM0GpiSyhCrS/oft5Ou+nmwpazYWYg0NAcMMjP1XjLOt38w==

备注:删除这条信息,重新 COPY 文件后不再报上述信息。

最后推荐和张文升共同编写的《PostgreSQL实战》,本书基于PostgreSQL 10 编写,共18章,重点介绍SQL高级特性、并行查询、分区表、物理复制、逻辑复制、备份恢复、高可用、性能优化、PostGIS等,涵盖大量实战用例!

购买链接:https://item.jd.com/12405774.html

PostgreSQL实战
感谢支持!
0%