SSH server not working (respawns until stopped)

I just had the same problem on my 12.04 box. I.e. same symptoms. Alas, it always happened when I introduced the ListenAddress clause with the inet and inet6 addresses in sshd_config. In short, this appears to be a symptom of a malformed sshd_config - although the log files didn't state anything like that.

Troubleshooting sshd

What I find generally very useful in any such cases is to start sshd without letting it daemonize. The problem in my case was that neither syslog nor auth.log showed anything meaningful.

When I started it from the terminal I got:

# $(which sshd) -Ddp 10222
/etc/ssh/sshd_config line 8: address family must be specified before ListenAddress.

Much better! This error message allowed me to see what's wrong and fix it. Neither of the log files contained this output.

NB: at least on Ubuntu the $(which sshd) is the best method to satisfy sshd requirement of an absolute path. Otherwise you'll get the following error: sshd re-exec requires execution with an absolute path. The -p 10222 makes sshd listen on that alternative port, overriding the configuration file - this is so that it doesn't clash with potentially running sshd instances. Make sure to choose a free port here.

This method has helped me many many times in finding issues, be it authentication issues or other types. To get really verbose output to stdout, use $(which sshd) -Ddddp 10222 (note the added dd to increase verbosity). For more debugging goodness check man sshd.


The main advantage of this method is that it allows you to check the sshd configuration without having to restart the sshd on the default port. Normally this should not interfere with existing SSH-connections, but I've seen it. So this allows one to validate the configuration file prior to - potentially - cutting off ones access to a remote server (for example I have that for some VPS and even for physical servers where I need to pay extra to get out-of-band access to the machine).


You should check to see what happened just before SSH started floundering in syslog. If the networking subsystem died, that could explain why sshd started failing.

I would also check /var/log/auth.log. It's sshd's log and it might give you a better error message.


This appears to be the result of bug #687535, which was fixed recently in natty, and has been uploaded to both maverick and lucid as a proposed update.

https://bugs.launchpad.net/ubuntu/lucid/+source/openssh/+bug/687535

I'd encourage everyone to go there, try the test case (search for TEST CASE), and post your results both before and after installing the proposed fix. That will help the SRU team decide that verification has been done and release it as an update.

Tags:

Ssh

Server

10.04