I thought ssh_exchange_identification: Connection closed by remote host
is caused by /etc/hosts.allow
and/or /etc/hosts.deny
, but allow's only entry is ALL:ALL
and deny is empty.
On my Google Cloud VM I've added:
ALL:ALL
to\etc\hosts.allow
and\etc\hosts.deny
is emptyA firewall rule setup for the Google Cloud VM to allow tcp:2222
GatewayPorts clientspecified
to/etc/ssh/sshd_config
From the destination (the computer I want to access) to my Google Cloud VM:
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>
After that Netstat -plant 2222
yields:
tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN 2700/0
Within the Google Cloud VM:
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
If I remove -p 2222, the ssh
command connects locally.