ssh 和 /root/.ssh/known_hosts 中 IP 的违规密钥

Tam*_*mpa 3 ssh

为什么或为什么我在服务器 A 尝试连接到服务器 B 时收到此错误???

ssh root@zk.111.sf.development.cloudera.fu.com
Warning: the ECDSA host key for 'zk.111.sf.development.cloudera.fu.com' differs from the key for the IP address '107.170.xxx.xxx'
Offending key for IP in /root/.ssh/known_hosts:4
Matching host key in /root/.ssh/known_hosts:5
Are you sure you want to continue connecting (yes/no)? no
Host key verification failed.
enter code here
Run Code Online (Sandbox Code Playgroud)

在服务器 AI 上执行此操作

eval `ssh-agent -s`
ssh-keyscan 107.170.xxx.xxx | tee -a /root/.ssh/known_hosts
Run Code Online (Sandbox Code Playgroud)

然后我尝试 ssh。哇..两个服务器事件都有相同的 pub 和 private 密钥。我正在尝试在服务器之间设置无密码身份验证。

Vin*_*rão 5

您的某些主机最近似乎更改了 IP,并且您在 IP 更改之后和之前都连接到了它们。

我建议您清理第 4 行和第 5 行中的known_hosts 文件以消除此错误消息。

另一件需要考虑的事情是:如果您只想让服务器 A 连接到服务器 B,则只需将服务器 A 公钥(id_dsa.pub 或 id_rsa.pub 的内容)放到服务器 B 的 /root/.ssh/authorized_keys 中即可。

如果您确实想要双向连接,您应该对服务器 B 到 A 执行相同的过程。


7ra*_*ack 5

从 ssh_config(5) 手册页来看,有一种模式

\n\n
\n

检查主机IP

\n\n

如果此标志设置为“yes”,ssh(1) 将另外检查known_hosts 文件中的主机\n IP 地址。这允许 ssh 检测主机密钥是否由于 DNS 欺骗而发生更改。如果该选项设置为“否”,则不会执行检查。默认为“是”。

\n
\n\n

因此,您可以将CheckHostIP no放入/etc/ssh/ssh_config 文件中。

\n\n
\n\n

正如 @Vin\xc3\xadcius Ferr\xc3\xa3o 所说,它不安全。最好的主意是将CheckHostIP no放入~/.ssh/config 文件中。这里是一个示例:

\n\n
Host bar.local bar\n    Hostname bar.local\n    CheckHostIP no\n
Run Code Online (Sandbox Code Playgroud)\n\n

您应该在 A 和 Bi 上执行相同的操作,认为这是启用 DHCP 的网络的最佳主意。

\n