kex_exchange_identification:读取:对等方重置连接。连接适用于其他 NIC/子网

one*_*ijk 8 networking ssh openssh

我重新安装了一个虚拟机(CentOS7),现在出现这个错误。VM 有两个位于不同子网上的适配器。
有趣的是,在修复了预期的 MITM 警告后,ssh 在一个子网上运行良好

ssh -v 显示:

OpenSSH_8.0p1, OpenSSL 1.1.1c  28 May 2019
debug1: Reading configuration data /home/user/.ssh/config
debug1: /home/user/.ssh/config line 6: Applying options for *
debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolving "foreman" port yy
debug2: ssh_connect_direct
debug1: Connecting to foreman [xxx.xxx.xxx.xxx] port yy.
debug1: Connection established.
debug1: identity file /home/sam/.ssh/id_rsa type 0
debug1: identity file /home/sam/.ssh/id_rsa-cert type -1
debug1: identity file /home/sam/.ssh/id_dsa type -1
debug1: identity file /home/sam/.ssh/id_dsa-cert type -1
debug1: identity file /home/sam/.ssh/id_ecdsa type -1
debug1: identity file /home/sam/.ssh/id_ecdsa-cert type -1
debug1: identity file /home/sam/.ssh/id_ed25519 type -1
debug1: identity file /home/sam/.ssh/id_ed25519-cert type -1
debug1: identity file /home/sam/.ssh/id_xmss type -1
debug1: identity file /home/sam/.ssh/id_xmss-cert type -1
debug1: Local version string SSH-2.0-OpenSSH_8.0
kex_exchange_identification: read: Connection reset by peer
Run Code Online (Sandbox Code Playgroud)

我试过了

  • 重启
  • 删除 known_hosts 文件
  • 在客户端检查 /etc/ssh/ssh_config (与维护者版本没有偏差)
  • 检查服务器上的 /etc/ssh/sshd_config (与维护者版本没有偏差)
  • 停止firewalld
  • 检查 .ssh/ 和 authorized_keys 的权限
  • 检查黑名单和白名单(没有任何内容,只有评论)(hosts.deny|hosts.allow)

我不确定它是否相关,但客户端正在运行 arch linux

所以,再次澄清
服务器有两个 ip 地址 172.xxx 和 192.xxx ssh 适用于 172.xxx 但不适用于 192.xxx

Bin*_*rus 2

对我来说,这听起来像是路由问题或网络掩码问题。我见过具有类似配置的情况,其中网络堆栈尝试对传出数据包使用错误的接口,即两个子网的传出数据包都通过第一个子网的接口进行路由。

因此,首先要测试的是是否可以从服务器ping每个子网中的另一台计算机,反之亦然。为了使测试过程不易出错,您应该将其他机器(客户端)配置为仅使用一个IP 地址(否则,测试可能会因为其他机器的配置错误而失败,从而产生误导)。

route -n接下来的事情是深入研究服务器和客户端上的输出。也许这已经表明了问题的原因。您介意发布该输出吗?

此外, 的输出ifconfig -a将很有用(同样在服务器和客户端上) - 我们最终希望了解您的网络掩码。

发布这些输出时,我认为您不需要混淆 IP 地址,只要它们来自私有范围即可。混淆本身可能容易出错,导致分析变得不可能。

如果您决定发布这些输出(请相应地编辑您的问题,而不是使用注释,因为输出可能很长),我将查看它并尝试找出发生了什么。