我認為ssh_exchange_identification: Connection closed by remote host
是由/etc/hosts.allow
and/or引起的/etc/hosts.deny
,但允許的唯一條目是ALL:ALL
而拒絕是空的。
在我的谷歌雲端虛擬機我已經添加:
ALL:ALL
到\etc\hosts.allow
且\etc\hosts.deny
為空防火牆規則設定谷歌雲端虛擬機允許 TCP:2222
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
命令將在本地連接。