kex_exchange_identification:读取:对端重置连接。连接在其他 NIC/子网上有效

kex_exchange_identification:读取:对端重置连接。连接在其他 NIC/子网上有效

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

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

我试过了

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

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

因此,再次澄清一下,
服务器有两个 IP 地址 172.xxx 和 192.xxx,ssh 适用于 172.xxx,但不适用于 192.xxx

答案1

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

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

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

此外,输出ifconfig -a会很有用(再次在服务器和客户端上) - 我们最终想了解您的网络掩码。

发布这些输出时,我认为只要 IP 地址属于私有范围,就无需对其进行混淆。混淆本身可能容易出错,导致无法进行分析。

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

答案2

我在稍微不同的情况下遇到了这个错误。在我的例子中,ssh-server 一开始就没有安装,直接安装并启动服务就可以解决问题。

需要注意的是,如果端口/ip/接口上没有 ssh 服务,无论是由于安装还是配置,都会发生此类错误。

相关内容