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))
  • 1
    Run ss -p -o state listening '( sport = :ssh )' to see what is listening on the port. Requires root. – Michael Hampton Mar 15 '17 at 2:08
  • 1
    Looks like sshd is somehow already running. Kill the given PID and then systemctl restart it. – Michael Hampton Mar 15 '17 at 2:12
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.

  • Does that mean that openssh in RHEL is getting rebased to 7.4? – Michael Hampton Mar 15 '17 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 '17 at 8:19
  • I was referring to your comment in the bug report. – Michael Hampton Mar 15 '17 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 '17 at 1:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.