
我已將 ssh 連接埠號碼從 22 更改為 2222 之前設定的連接到預設 ssh 連接埠 22 沒問題 我已正確映射路由器上的 NAT
當我嘗試調試它時
ssh -v -p2222 www.example.com
我收到此錯誤掛起
debug1: SSH2_MSG_KEXINIT
以下是所有調試日誌
bob@server:~$ ssh -v -p2222 www.example.com
OpenSSH_4.7p1 Debian-8ubuntu1.2, OpenSSL 0.9.8g 19 Oct 2007
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: Applying options for *
debug1: Connecting to www.example.com [100.100.100.100] port 2222.
debug1: Connection established.
debug1: identity file /home/bob/.ssh/identity type -1
debug1: identity file /home/bob/.ssh/id_rsa type -1
debug1: identity file /home/bob/.ssh/id_dsa type -1
debug1: Remote protocol version 2.0, remote software version OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: match: OpenSSH_4.7p1 Debian-8ubuntu1.2 pat OpenSSH*
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_4.7p1 Debian-8ubuntu1.2
debug1: SSH2_MSG_KEXINIT sent
Connection closed by 100.100.100.100
就像連接關閉一樣,我在網路內外的幾台機器上使用了 gnome-terminal、putty、securecrt 仍然遇到相同的錯誤
答案1
我剛剛在 XEN 主機上發生過這種情況。我從另一個主機複製了這個主機,按照慣例,我在執行此操作後刪除了 /etc/ssh 中的主機金鑰,認為稍後會產生新的主機金鑰。但這從未發生過,而且 sshd 在沒有主機金鑰的情況下愉快地啟動了。當嘗試 ssh 到該主機時,它會在 SSH2_MSG_KEXINIT 之後退出。我所要做的就是建立主機金鑰,在基於 debian 的機器上是這樣完成的:
dpkg-reconfigure openssh-server
答案2
我遇到了這個問題,並透過將目標路由器/防火牆和目標主機上的 MTU 設定為與來源主機相同(1500)來解決它。
答案3
我遇到了同樣的問題,當我更改 sshd_config 中的連接埠並重新啟動 sshd 服務時,sshd 感到困惑,當我最終查看伺服器日誌(看起來你不能)時,sshd 抱怨連接埠已經存在使用,netstat 同意,並且ps 顯示了sshd 服務的多個實例正在運作。我殺死了它們並再次啟動 sshd,並且能夠連接。我發誓我嘗試重新啟動來解決問題,但我想不會,因為這可能會解決問題。
長話短說,應該在連接埠 2222 上偵聽以對您進行身份驗證的 sshd 並不是實際偵聽的,而是另一個 sshd 進程。如果你也有跟我一樣的問題。
答案4
SSH2_MSG_KEXINIT 不是錯誤。它只是告訴您它正在開始 ssh 密鑰交換過程。
如果另一端此時正在關閉連接,顯然它出於某種原因不喜歡你:-) 來自遠端的日誌可能包含有關連接為何突然關閉的資訊。 (例如 TCP 包裝器)