我已经通过 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)
在做了一些研究之后,我尝试了以下...
请注意,我没有对服务器进行任何更改来禁止这种通信。
另外,我不确定这是否会导致问题,但我已经通过它的域名和 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可以解决问题,但在某些情况下我不得不做2..我无法弄清楚为什么会出现这种情况,只是它有效。也许它与密钥的呈现方式有关,或者它可能以某种方式被损坏 - 我不确定。但我所知道的是,该错误完全与服务器以及设置 SSH 连接时握手的方式有关。