當 ssh 連線失敗時,dispatch_protocol_error: type 51 seq 5 是什麼意思以及如何解決?

當 ssh 連線失敗時,dispatch_protocol_error: type 51 seq 5 是什麼意思以及如何解決?

我正在嘗試使用以下命令透過 SSH 連接到 Linux 伺服器:

ssh [email protected] -p 22

但是,我無法連接到它。只有一則訊息,dispatch_protocol_error: type 51 seq 5。 ssh 命令掛起約一兩分鐘,直到它關閉並顯示以下訊息:

Connection to ip.of.server.com closed by remote host.
Connection to ip.of.server.com closed.

在Google 中搜尋dispatch_protocol_error 訊息並沒有得到與此特定調度協定錯誤相關的任何內容,大多數人詢問不同的調度協定錯誤(具有type 和seq 的其他值),並且在這些錯誤中都沒有任何關於此錯誤的解釋錯誤訊息的意思。

唯一或多或少有趣的是此 OpenSSH 常見問題解答,其中一個問題是關於“調度協定錯誤:類型 20”,這是因為“舊版本的 OpenSSH 不支援會話重新產生金鑰”而發生的。它建議我添加RekeyIntervalSeconds 0到“SSH 2.3's ssh2_config 或 sshd2_config”。為了看看會發生什麼,我嘗試將其添加到我的(客戶端)ssh_config(我沒有 ssh2_config 檔案),但這沒有幫助(事實上,這是一個「錯誤的配置選項」)。

我嘗試不使用連接埠()進行連接,結果是一樣的。我也嘗試過ssh [email protected]從已知主機清單中刪除該主機透過使用ssh-keygen -R hostname,假設這是當前 RSA 金鑰指紋的問題。但是,這不允許我連接,並且顯示了相同的錯誤訊息。

我使用的是 Ubuntu 16.04,伺服器是 CentOS 6.8。我的 SSH(客戶端)版本是 7.2 版本(來自這個答案ssh -v localhost:) :

OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g

我的猜測是,這是伺服器中的問題,所以我無法僅透過在電腦上工作來解決它,我的老闆也同意這一點。

所以,我的問題是,該錯誤訊息的含義以及解決方法

Ps:我不是 SSH 的專家,所​​以我可能做了非常愚蠢的操作,並且錯過了解決這個問題的一些必要的東西。

編輯:我使用 -v(詳細)選項運行 ssh。根據它,我能夠連接並進行身份驗證(debug1: Authentication succeeded (none).)。在此訊息之後,有以下訊息,包括我的錯誤。完整日誌如下:

OpenSSH_7.2p2 Ubuntu-4ubuntu2.2, OpenSSL 1.0.2g  1 Mar 2016
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to ip.of.server.com [ip.of.server.com] port 22.
debug1: Connection established.
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuser/.ssh/id_rsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuser/.ssh/id_rsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuser/.ssh/id_dsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuser/.ssh/id_dsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuser/.ssh/id_ecdsa type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuser/.ssh/id_ecdsa-cert type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuser/.ssh/id_ed25519 type -1
debug1: key_load_public: No such file or directory
debug1: identity file /home/myuser/.ssh/id_ed25519-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_7.2p2 Ubuntu-4ubuntu2.2
debug1: Remote protocol version 2.0, remote software version OpenSSH_5.3
debug1: match: OpenSSH_5.3 pat OpenSSH_5* compat 0x0c000000
debug1: Authenticating to ip.of.server.com:22 as 'root'
debug1: SSH2_MSG_KEXINIT sent
debug1: SSH2_MSG_KEXINIT received
debug1: kex: algorithm: diffie-hellman-group-exchange-sha256
debug1: kex: host key algorithm: ssh-rsa
debug1: kex: server->client cipher: aes128-ctr MAC: [email protected] compression: none
debug1: kex: client->server cipher: aes128-ctr MAC: [email protected] compression: none
debug1: SSH2_MSG_KEX_DH_GEX_REQUEST(2048<3072<8192) sent
debug1: got SSH2_MSG_KEX_DH_GEX_GROUP
debug1: SSH2_MSG_KEX_DH_GEX_INIT sent
debug1: got SSH2_MSG_KEX_DH_GEX_REPLY
debug1: Server host key: ssh-rsa SHA256:server_host_key_ssh_rsa_is_here
debug1: Host 'ip.of.server.com' is known and matches the RSA host key.
debug1: Found key in /home/myuser/.ssh/known_hosts:6
debug1: rekey after 3249842342 blocks
debug1: SSH2_MSG_NEWKEYS sent
debug1: expecting SSH2_MSG_NEWKEYS
debug1: rekey after 3249842342 blocks
debug1: SSH2_MSG_NEWKEYS received
debug1: SSH2_MSG_SERVICE_ACCEPT received
debug1: Authentication succeeded (none).
Authenticated to ip.of.server.com ([ip.of.server.com]:22).
debug1: channel 0: new [client-session]
debug1: Requesting [email protected]
debug1: Entering interactive session.
debug1: pledge: network
dispatch_protocol_error: type 51 seq 5
debug1: Received SSH2_MSG_UNIMPLEMENTED for 6
debug1: Received SSH2_MSG_UNIMPLEMENTED for 7
debug1: Received SSH2_MSG_UNIMPLEMENTED for 9
debug1: Received SSH2_MSG_UNIMPLEMENTED for 10
debug1: Received SSH2_MSG_UNIMPLEMENTED for 11
debug1: Received SSH2_MSG_UNIMPLEMENTED for 12

... (there are lots of this SSH2_MSG_UNIMPLEMENTED message)

debug1: Received SSH2_MSG_UNIMPLEMENTED for 60
debug1: Received SSH2_MSG_UNIMPLEMENTED for 61
debug1: channel 0: free: client-session, nchannels 1
debug1: fd 1 clearing O_NONBLOCK
debug1: channel 0: free: client-session, nchannels 1
Connection to ip.of.server.com closed by remote host.
Connection to ip.of.server.com closed.
Transferred: sent ..., received ... bytes, in ... seconds
Bytes per second: sent ..., received ...
debug1: Exit status -1

關於伺服器端:尋找 CentOS 的 sshd 日誌(/var/log/secure,如這個答案顯示),唯一相關的結果是類似錯誤的重複:

Jan  5 14:38:44 myserverside sshd[1234]: dispatch_protocol_error: type 90 seq 6
Jan  5 14:38:44 myserverside sshd[1234]: dispatch_protocol_error: type 80 seq 7
Jan  5 14:38:46 myserverside sshd[1234]: dispatch_protocol_error: type 80 seq 9
Jan  5 14:38:48 myserverside sshd[1234]: dispatch_protocol_error: type 80 seq 10
Jan  5 14:38:50 myserverside sshd[1234]: dispatch_protocol_error: type 80 seq 11
Jan  5 14:38:52 myserverside sshd[1234]: dispatch_protocol_error: type 80 seq 12

...

Jan  5 14:40:31 myserverside sshd[1234]: dispatch_protocol_error: type 80 seq 60
Jan  5 14:40:33 myserverside sshd[1234]: dispatch_protocol_error: type 80 seq 61

此條目之前和之後的其他條目(具有其他 ID)並非來自此特定嘗試(它們來自我成功的 PuTTY 連接,正如我在時間數據中看到的那樣)。應該注意的是,這些錯誤訊息中的數字與我在客戶端得到的數字相同。

嘗試使用 -M 標誌 ( ) 會導致相同的錯誤。ssh -M [email protected]

奇怪的是,使用舊版 Ubuntu (Ubuntu 12.04) 的客戶端我能夠連線。所以可能是版本不相容(伺服器太舊和/或客戶端太新) - 也許是最近更新的 SSH,因為大約一個月前我能夠使用 Ubuntu 16.04 電腦進行連接,或者可能是設定問題。

Ps:我能夠透過PuTTY(Ubuntu版本)成功連線。所以這個問題只發生在嘗試透過 SSH 連線時。

相關內容