sshd seems to be run multiple times at startup

Bug #129789 reported by xbx
8
This bug affects 1 person
Affects Status Importance Assigned to Milestone
sysvinit
Invalid
Undecided
Unassigned
upstart
Invalid
Undecided
Unassigned
openssh (Debian)
Fix Released
Unknown
openssh (Ubuntu)
Fix Released
Undecided
Colin Watson

Bug Description

I see in auth.log logs everytime I boot something similar to this:

Aug 1 20:43:52 xbx-laptop sshd[5446]: Server listening on :: port 22.
Aug 1 20:43:52 xbx-laptop sshd[5446]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
Aug 1 20:44:02 xbx-laptop ssh-agent[5797]: error: Unknown message 252
Aug 1 20:51:16 xbx-laptop sshd[5446]: Received SIGHUP; restarting.
Aug 1 20:51:16 xbx-laptop sshd[10012]: Server listening on :: port 22.
Aug 1 20:51:16 xbx-laptop sshd[10012]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
Aug 1 20:56:47 xbx-laptop sshd[5513]: Server listening on :: port 22.
Aug 1 20:56:47 xbx-laptop sshd[5513]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.

that's odd,
(but in the end the ssh does work)

Revision history for this message
xbx (xavierb) wrote :

 it's with gutsy

Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Mindbogglingly unlikely to be an Upstart bug

Changed in upstart:
status: New → Invalid
Revision history for this message
Scott James Remnant (Canonical) (canonical-scott) wrote :

Not an upstream bug for sysvinit

Changed in sysvinit:
status: New → Invalid
Revision history for this message
Colin Watson (cjwatson) wrote :

Could I see the output of this command, please?

  ls -l /etc/rc*.d/*ssh*

Changed in openssh:
assignee: nobody → kamion
status: New → Incomplete
Revision history for this message
xbx (xavierb) wrote :

sure.

ls -l /etc/rc*.d/*ssh*
lrwxrwxrwx 1 root root 13 2007-11-25 15:25 /etc/rc1.d/K84ssh -> ../init.d/ssh
lrwxrwxrwx 1 root root 13 2007-11-25 15:25 /etc/rc2.d/S16ssh -> ../init.d/ssh
lrwxrwxrwx 1 root root 13 2007-11-25 15:25 /etc/rc3.d/S16ssh -> ../init.d/ssh
lrwxrwxrwx 1 root root 13 2007-11-25 15:25 /etc/rc4.d/S16ssh -> ../init.d/ssh
lrwxrwxrwx 1 root root 13 2007-11-25 15:25 /etc/rc5.d/S16ssh -> ../init.d/ssh

I'm not sure, but I think I have reinstalled from scratch since the intial bug report. But I checked, I still get this in the log at every boot:
Feb 28 11:12:00 xbx-laptop sshd[5368]: Server listening on :: port 22.
Feb 28 11:12:01 xbx-laptop sshd[5368]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.

but no longer
"ssh-agent[5797]: error: Unknown message 252" nor "Received SIGHUP; restarting."

Revision history for this message
Adam Stovicek (arstovicek) wrote :

I found this fix elsewhere.

Open /etc/ssh/sshd_config for editing. Uncomment the listening address for 0.0.0.0.

# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
#ListenAddress 0.0.0.0

Change to:

# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
ListenAddress 0.0.0.0

I'm not sure why this needs to be done. I've got a number of Ubuntu/Debian machines and this was the first time I came across this problem. It was with Ubuntu 8.04 Beta.

Revision history for this message
Adam Stovicek (arstovicek) wrote :

Sorry. After making the change I mentioned above, you'll need to restart the server.

sudo /etc/init.d/ssh restart

Revision history for this message
Dustin Kirkland  (kirkland) wrote :

@xbx:

Do you happen to know if you're on an ipv4 or an ipv6 network?

If you're an ipv4 network, try disabling ipv6 and enabling ipv4 listening in your /etc/ssh/sshd_config:
    #ListenAddress ::
    ListenAddress 0.0.0.0

Alternatively, if you're on an ipv6 network, try disabling ipv4 and enabling ipv6:
    ListenAddress ::
    #ListenAddress 0.0.0.0

Note this thread on the Fedora Forums:
   http://www.fedoraforum.org/forum/archive/index.php/t-26887.html

Revision history for this message
Thierry Carrez (ttx) wrote :

@xbx:

There are two separate issues.

First, the default setup is noisy : both ipv4 and ipv6 are configured on the network interface, and without a ListenAddress sshd will try to bind both, resulting in the "Address already in use" message.

Second, everytime the network interface goes up (say, you finally get your ipv4 address from your DHCP server), if-up restarts sshd (the "SIGHUP" message) to let it pick up that new interface.

Are you using DHCP ?

Revision history for this message
xbx (xavierb) wrote : Re: [Bug 129789] Re: sshd seems to be run multiple times at startup

yes, I'm using dhcp (with a wifi connection), with ipv4

I just checked the log, and the error is still there.
But sshd works perfectly, it's just a log line that looks odd...
I actually don't remember why I filled this bug. I guess I was
looking for some other issue at the time, and stumbled upon this...

Revision history for this message
xbx (xavierb) wrote :

and uncommenting the line "ListenAddress 0.0.0.0" in /etc/ssh/sshd_config:

   #ListenAddress ::
   ListenAddress 0.0.0.0

fixes the issue.

Revision history for this message
Colin Watson (cjwatson) wrote :

This was http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=439661, fixed in OpenSSH 5.1p1; your workarounds with ListenAddress are fine for now, or I think most systems can just ignore this error.

Changed in openssh:
status: Incomplete → Fix Released
Changed in openssh:
status: Unknown → Fix Released
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.