Eu pensei que ssh_exchange_identification: Connection closed by remote host é causado por /etc/hosts.allow e / ou /etc/hosts.deny , mas a única entrada permitida é ALL:ALL e a negação está vazia.
Na minha VM do Google Cloud , adicionei:
ALL:ALL to \etc\hosts.allow e \etc\hosts.deny está vazio
Uma configuração de regra de firewall para a VM do Google Cloud para permitir tcp: 2222
GatewayPorts clientspecified a /etc/ssh/sshd_config
Do destino (o computador que desejo acessar) para minha VM do Google Cloud :
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>
Depois disso, Netstat -plant 2222 produz:
tcp 0 0 0.0.0.0:2222 0.0.0.0:* LISTEN 2700/0
Na VM do Google Cloud :
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
Se eu remover -p 2222, o comando ssh se conectará localmente.