ssh_exchange_identification: Connection closed by remote host と言われたときにクライアント側でできる対処


家のネット回線を変えてからsshしたときに

$ ssh hoge
ssh_exchange_identification: Connection closed by remote host

と言われました。
このようなとき、クライアント側で~/.ssh/known_hostsを削除すると、再び接続できるようになりました。

$ rm ~/.ssh/known_hosts
$ ssh hoge
The authenticity of host 'x.x.x.x (y.y.y.y)' can't be established.
RSA key fingerprint is xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added 'x.x.x.x' (RSA) to the list of known hosts.
<<正常にログインできる>>

おそらく、known_hostsに前の接続情報が残っていてコンフリクトを起こしたのでしょう。

なお、他の原因として、サーバ側で/etc/hosts.allowをいじったことなどもありますが、この辺はググってみてください。