SSH 连接:ssh_exchange_identifcation

Dyl*_*lan 9 ssh macos

我已经通过 Mac 连接到远程服务器大约一个月了。不过最近,我尝试使用 ssh dylan@MY_IP 进行连接并收到此消息。

ssh_exchange_identification: read: Connection reset by peer
Run Code Online (Sandbox Code Playgroud)

我也得到了一些诊断信息...

debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 53: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to {MY IP{ [MY IP] port 22.
debug1: Connection established.
debug1: identity file /Users/watson/.ssh/id_rsa type -1
debug1: identity file /Users/watson/.ssh/id_rsa-cert type -1
debug3: Incorrect RSA1 identifier
debug3: Could not load "/Users/watson/.ssh/id_dsa" as a RSA1 public key
debug1: identity file /Users/watson/.ssh/id_dsa type 2
debug1: identity file /Users/watson/.ssh/id_dsa-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.2
Run Code Online (Sandbox Code Playgroud)

在做了一些研究之后,我尝试了以下...

  1. 重新启动我的路由器
  2. 清除了我的“known_hosts”文件
  3. 删除了我的“known_hosts”文件
  4. 发布并更新了我的 DHCP
  5. 我也试过在另一台设备(Windows)上使用 Putty 也有错误

请注意,我没有对服务器进行任何更改来禁止这种通信。

另外,我不确定这是否会导致问题,但我已经通过它的域名和 IP 连接到它。

此外,我能够从另一个 IP 地址成功连接。

我知道这是一个有很多资源的大问题,但是很多解决方案都不起作用,我也没有真正看到任何类型的解决方案。

更新

我强迫它使用协议 1。而不是“由对等方重置连接”,我现在得到“远程主机关闭连接”。运行它并显示调试信息:

debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: /etc/ssh_config line 53: Applying options for *
debug2: ssh_connect: needpriv 0
debug1: Connecting to MY_IP [MY_IP] port 22.
debug1: Connection established.
debug1: identity file /Users/watson/.ssh/identity type -1
debug1: identity file /Users/watson/.ssh/identity-cert type -1
ssh_exchange_identification: Connection closed by remote host
Run Code Online (Sandbox Code Playgroud)

小智 1

这不是您本地机器的问题,而是服务器端的问题。导致此问题的因素可能有多种

  1. 远程服务器上 /etc/hosts.allow 或 /etc/hosts.deny 配置的更改。
  2. 服务器负载重。

过去,当我遇到这些问题时,我按照以下顺序做了两件事之一:

  1. 按照上面文章中引用的方式修改 /etc/hosts.allow。(并重新启动SSH服务器)
  2. 如果 /etc/hosts.allow 已经符合要求,只需重新启动 SSH 服务器(执行此操作时要小心!)
  3. 如果重新启动不起作用,请重新生成服务器密钥并重新启动 SSH 服务器(这是有风险的,因为登录到这台计算机的每个用户都会收到有关服务器密钥已更改的错误)

通常情况下,1可以解决问题,但在某些情况下我不得不做2..我无法弄清楚为什么会出现这种情况,只是它有效。也许它与密钥的呈现方式有关,或者它可能以某种方式被损坏 - 我不确定。但我所知道的是,该错误完全与服务器以及设置 SSH 连接时握手的方式有关。