1

I have a Centos 7 server and sshd is running and accepting connections just fine.

The problem is, that messages log keeps reporting failed sshd startup attempts and secure log keeps reporting that sshd can't start because port 22 is in use.

messages;

Mar 15 12:03:01 ded2100 systemd[1]: Starting Session 10614 of user root.
Mar 15 12:03:05 ded2100 systemd[1]: sshd.service start operation timed out. Terminating.
Mar 15 12:03:05 ded2100 systemd[1]: Failed to start OpenSSH server daemon.
Mar 15 12:03:05 ded2100 systemd[1]: Unit sshd.service entered failed state.
Mar 15 12:03:05 ded2100 systemd[1]: sshd.service failed.

secure;

Mar 15 12:01:34 ded2100 sshd[14947]: error: Bind to port 22 on 0.0.0.0 failed: Address already in use.
Mar 15 12:01:34 ded2100 sshd[14947]: error: Bind to port 22 on :: failed: Address already in use.

Today my server failed. SSH went as well requiring a hard reboot and I want to make sure sshd is as solid as it can be so I can rest assured if it can be up, it will be up.

Thanks.

EDIT
My sshd_config is here - https://gist.github.com/cbiggins/3cb4fcc1af25da63e89b1fab2eb7d57c

EDIT #2

[root@ded2100 log]# ss -p -o state listening '( sport = :ssh )'
Netid  Recv-Q Send-Q                                  Local Address:Port                                                   Peer Address:Port
tcp    0      128                                                 *:ssh                                                               *:*                     users:(("sshd",pid=1956,fd=3))
tcp    0      128                                                :::ssh                                                              :::*                     users:(("sshd",pid=1956,fd=4))
2
  • 1
    Run ss -p -o state listening '( sport = :ssh )' to see what is listening on the port. Requires root. Mar 15, 2017 at 2:08
  • 1
    Looks like sshd is somehow already running. Kill the given PID and then systemctl restart it. Mar 15, 2017 at 2:12

2 Answers 2

2

This is known bug, that systemd is unable to keep track of running service with RHEL7.3/CentOS7.3.

Especially, this is problem of services with Type=forking. Systemd starts the service, checks the PID file (which is not written yet in some cases) and considers the service as failed. Then tries to start the service again, which obviously fails.

The update is on the way. To resolve the problem in one-shot, just kill the running sshd (pid 1956 in your case) and start a new one with systemctl start sshd.

4
  • Does that mean that openssh in RHEL is getting rebased to 7.4? Mar 15, 2017 at 8:15
  • It is unrelated to the OpenSSH version. It is only problem with systemd, service file and SD_NOTIFY functionality (which is not in upstream). But yes, it looks like that.
    – Jakuje
    Mar 15, 2017 at 8:19
  • I was referring to your comment in the bug report. Mar 15, 2017 at 8:22
  • Thanks. The server had to be rebooted overnight and it would appear that the reboot has resolved the issue based on this bug and your post.
    – Christian
    Mar 16, 2017 at 1:30
0

Thanks guys! Fist I did:

[root@xxx ~]# ss -panetl | grep :22
LISTEN     0      128          *:22                       *:*                   users:(("sshd",pid=20453,fd=3)) ino:218041529 sk:ffff8dcb94b43e00 <->
LISTEN     0      128         :::22                      :::*                   users:(("sshd",pid=20453,fd=4)) ino:218041531 sk:fff

Then I kill the process and restart sshd. This work for me.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .