SSH: Connection closed by remote server

Had the same issue but a simple remote server reboot helped.


Are you sure your server is permitting root logins via SSH? If not, I suggest using a different account with sudo privileges instead of enabling root login - especially if the server's SSH port is accessible from the whole inernet.


I was getting the same "Connection closed by {ip_address}" error on one of my SSH connections. I tried all the usual solutions and nothing worked. Finally I found that the ~/.ssh/authorized_keys file on the host was corrupted. Someone had tried to append a key to the file, but they copied and pasted it with embedded line feeds where each line wrapped at the end. So what should have been one continuous string spanning three lines was actually three separate strings -- one per line. Since the embedded line feed was exactly at the end of the line, it was not apparent from looking at it.

I deleted the offending key and added my own. Then everything worked as expected.


try sudo ssh root@{ip_address}, it works for me.