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))
Best Answer
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
(pid1956
in your case) and start a new one withsystemctl start sshd
.