

I've just had this exact issue, and the cause was that I had a port translation happening internally to the load balancer, meaning that my ssh connections were reaching the host on port 80 instead of port 22. So, what causes error: kex_exchange_identification: Connection closed by remote host?


ssh/authorized_keys2 /etc/ssh/authorized_keys.d/%uĪfter searching the web, I have seen references to MaxStartups indicating that it could be the reason for this error but after changing the default value as shown in my sshd_config and attempting more than 3 connections, the server unambiguously indicates the probem Apr 20 07:26:59 myhostname sshd: drop connection #3 from :54986 on :22 past MaxStartups Īpr 20 03:39:48 myhostname sshd: Connection from x.x.x.207 port 39332 on 10.0.0.11 port 22 rdomain ""Īpr 20 03:39:48 myhostname sshd: Connection from x.x.x.207 port 39334 on 10.0.0.11 port 22 rdomain ""Īpr 20 03:39:48 myhostname sshd: Connection closed by x.x.x.207 port 39332 Īpr 20 03:39:48 myhostname sshd: Connection closed by x.x.x.207 port 39334 Īpr 20 03:59:36 myhostname sshd: Connection from x.x.x.83 port 34876 on 10.0.0.11 port 22 rdomain ""Īpr 20 03:59:36 myhostname sshd: error: kex_exchange_identification: Connection closed by remote hostĪnd here is my SSH configuration: # ssh -VĪuthorizedKeysFile. Here is 30 minutes of SSH logs (public IPs have been redacted): # journalctl SYSLOG_IDENTIFIER=sshd -S "03:30:00" -U "04:00:00" I can myself connect and authenticate without any problem.įrom time to time, I get the error: kex_exchange_identification: Connection closed by remote host in the server logs. Weirdly, none actually try to authenticate to open a session. Therefore, I get a lot of connections from IPs all over the world. I setup a SSH server online that is publicly accessible by anyone.
