security - 如何在同一(但不断变化的)IP 地址上处理 2 个不同主机的 ssh 主机 key 验证?

标签 security ssh verification nat openssh

关闭。这个问题是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.


UsernamePort line 避免了你不得不在命令行上提供这些选项,所以你可以使用:
% ssh server1
% ssh server2

关于security - 如何在同一(但不断变化的)IP 地址上处理 2 个不同主机的 ssh 主机 key 验证?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/733753/

相关文章:

security - 银行在其密码生成器 token 上使用哪种 OTP(一次性密码)算法?

ssh - Notepad++ 和 SFTP 连接问题

vba - Excel 2007 VBA - Avaya CMS - SSH 破坏脚本

bash - 通过 ssh 运行远程 bash 命令

google-plus - 我该如何制作一个Google验证框来将人们注册到我的网站?

php - 存储注册时输入的数据

java - 安全删除通行证数量

javascript - Firefox Scratchpad 的 javascript 代码比标准网站 javascript 代码拥有更多权限?

java - Axis2 Web 服务 SSL 通信

payment - 处理付款时验证信用卡所有权