SSH won’t automatically start at startup – a solution

Posted: 2010/06/24 in Linux

Problem: SSH won’t autostart

Circumstance: New installation of Ubuntu 10.04 (Lucid Lynx), desktop.  Using ufw (fun) and Samba.  Using OpenSSH.  Setup is pretty normal: using port 22 and another.

Looked all over the web only to find all kinds of possible problems.  I first tried adding SSH to the /etc/rc?.d directories (rc5 and rc3):

cd /etc/rc3.d
ln -s ../init.d/ssh SS99ssh

Reboot… no dice.  So I searched (grep’d) /var/log/auth.log and saw that my server was not ‘binding’ to the address I had designated using the ListenAddress directive in /etc/ssh/sshd_config

cat /etc/ssh/sshd_config | grep ListenAddress

cat /var/log/auth.log | grep sshd
Jun 24 ….. sshd[xxxx]:  fatal: Cannot bind any address
Jun 24 ….. sshd[xxxx]:  error: Bind to port 22 on failed: Cannot assign requested address

Hmm… read, search, read, search…  Finally came across a solution to my situation.  I decided to NOT use ListenAddress.  I simply commented out that line and rebooted. It worked!  Now, I get the following output:

cat /var/log/auth.log | grep sshd
Jun 24 ….. sshd[xxxx]:  Server listening on port 22

Upon further searching, I found that the OS didn’t know it was at until after sshd had tried to start. This is evidenced by the fact that if I leave the ListenAddress active, sshd does not autostart but I can get it to start-up from the command line (sudo service ssh start) with no problem.  The auth.log output says ‘Server listening on port 22’

I’m pretty sure there’s a way to get the OS to know what IP it is before sshd tries to initialize, but I haven’t figured that out yet… maybe soon (if I get the time).

  1. Alexander says:

    auto ethX
    iface ethX inet dhcp
    up service ssh start

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s