Friday, 1 July 2016

Troubleshooting "ssh: connection closed by remote host"

So the error "ssh: connection closed by remote host" is one of the most common & pesky errors I've experienced as a system administrator.

Some of the troubleshooting & diagnostics I've learned over the years are as follows:

Note: You'll need console access to the server you're trying to ssh into.

  • Do an ssh -vvv <hostname> to get more detailed information as to why the connection is not getting established.
  • Check the status of ssh service on the destination server.
  • Check for space utilization of /,/var & /tmp file systems with df. Space constraints in these mount points can prevent logins.
  • Check permissions of /var & /etc & make sure they are not 777. The 'secure' in 'secure shell' kicks in & won't allow logins if permissions of /var & /etc are world readable. Also if the permissions of home directory of login user on destination server is set to 777 that would again cause a 'no login'.
  • Check the status of login user on destination server to make sure its not expired or locked. I know it sounds basic but still a valid check.
  • If you are using ssh keys for authentication make sure the authorized_keys file on destination server is syntactically correct.
  • Finally, check for nproc values on the destination server. Sometimes if the server is under heavy load & has a lot of processes running, the nproc value can inhibit the creation of new shell processes to conserve system resources thereby preventing login.


I hope these tips help save time the next time you see this error.

No comments:

Post a Comment

Using capture groups in grep in Linux

Introduction Let me start by saying that this article isn't about capture groups in grep per se. What we are going to do here with gr...