SSH — Connection closed by remote host Solution.

Hopefully this will save some people time.

A quick google search will show that the connection closed by remote host error is common, and not many people seem to have an answer as to what cause it.

Some point to the /etc/hosts.allow and /etc/hosts.deny as being the issue, others say it may be a hardware error, an sshd configuration, or broken glibc upgrades.

HOWEVER, the two most common causes I’ve seen, are (as far as I could see) not mentioned anywhere, and are caused by simple human error.

First: Ensure sshd is actually running on the remote host. If it isn’t, well then you won’t be able to connect.

Second: Ensure the port you are trying to access (default is 22) is open. Particularly relevant when using docker containers, where your AREN’T accessing 22. You can use the -p flag in your ssh command to connect to a designated port, E.G:

ssh user@hostname -p 24

One clap, two clap, three clap, forty?

By clapping more or less, you can signal to us which stories really stand out.