什麼可能導致 SSH 登入錯誤:ssh_exchange_identification:連線被遠端主機關閉

什麼可能導致 SSH 登入錯誤:ssh_exchange_identification:連線被遠端主機關閉

我認為ssh_exchange_identification: Connection closed by remote host是由/etc/hosts.allowand/or引起的/etc/hosts.deny,但允許的唯一條目是ALL:ALL而拒絕是空的。

在我的谷歌雲端虛擬機我已經添加:

  1. ALL:ALL\etc\hosts.allow\etc\hosts.deny為空

  2. 防火牆規則設定谷歌雲端虛擬機允許 TCP:2222

  3. GatewayPorts clientspecified/etc/ssh/sshd_config

來自目的地(我想要存取的電腦)到我的谷歌雲端虛擬機:

ssh -R 0.0.0.0:2222:localhost:22 -i google_compute_engine -o UserKnownHostsFile=/dev/null -o CheckHostIP=no -o StrictHostKeyChecking=no <username>@<google vm ip>

之後Netstat -plant 2222產生:

tcp        0      0 0.0.0.0:2222            0.0.0.0:*               LISTEN      2700/0

谷歌雲端虛擬機:

ssh -p 2222 -i google_compute_engine localhost -v

OpenSSH_6.6.1, OpenSSL 1.0.1f 6 Jan 2014
debug1: Reading configuration data /etc/ssh/ssh_config
debug1: /etc/ssh/ssh_config line 19: Applying options for *
debug1: Connecting to localhost [127.0.0.1] port 2222.
debug1: Connection established.
debug1: identity file google_compute_engine type -1
debug1: identity file google_compute_engine-cert type -1
debug1: Enabling compatibility mode for protocol 2.0
debug1: Local version string SSH-2.0-OpenSSH_6.6.1p1 Ubuntu-2ubuntu2.3
ssh_exchange_identification: Connection closed by remote host

如果我刪除 -p 2222,該ssh命令將在本地連接。

相關內容