关闭。这个问题是off-topic .它目前不接受答案。
想改进这个问题? Update the question所以它是on-topic对于堆栈溢出。
10年前关闭。
社区在 5 个月前审查了是否重新打开此问题并将其关闭:
原始关闭原因未解决
Improve this question
我在 nat 防火墙后面有 2 个 ssh 服务器,位于每天更改其 wan IP 的位置。它们在给定时间始终位于相同的 wan IP 地址,但位于不同的端口。
我以这种方式连接到服务器 A:
ssh -p 22001 karl@x1.example.com
和服务器 B:
ssh -p 22002 karl@x2.example.com
因此,我为同一 IP 获得了 2 个不同的主机 key ,并且当 IP 更改时,甚至同一主机的不同 IP 也是如此。
我必须一遍又一遍地删除 known_hosts 文件中的另一个 key 或旧 key (在 IP 更改的情况下)。
我正在犹豫是否要关闭 key 验证,因为这样会不太安全。但是一直收到警告也是不安全的(因为那时我一直忽略此类警告)。有更好的解决方案吗?
这与我的旧问题有关,但不一样:
SSH login warning message on a server with 2 DNS names
最佳答案
我认为这会起作用:
创建 config
文件在您的.ssh
目录如下:
Host server1
Hostname x1.example.com
HostKeyAlias server1
CheckHostIP no
Port 22001
User karl
Host server2
Hostname x2.example.com
HostKeyAlias server2
CheckHostIP no
Port 22002
User karl
解释如下(来自
man ssh_config
)CheckHostIP
If this flag is set to "yes", ssh(1) will additionally check the host IP address in the known_hosts file. This allows ssh to detect if a host key changed due to DNS spoofing. If the option is set to "no", the check will not be executed. The default is "yes".
HostKeyAlias
Specifies an alias that should be used instead of the real host name when looking up or saving the host key in the host key database files. This option is useful for tunneling SSH connections or for multiple servers running on a single host.
Username
和 Port
line 避免了你不得不在命令行上提供这些选项,所以你可以使用:% ssh server1
% ssh server2
关于security - 如何在同一(但不断变化的)IP 地址上处理 2 个不同主机的 ssh 主机 key 验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/733753/