大网数据广告活动
服务器运维问答

sshd is already running though keeps trying to start

· 52CE 我爱测

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…

问题原文

原帖链接 · Christian · CC BY-SA 3.0

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))

已采纳解答

原帖链接 · Jakuje · CC BY-SA 3.0

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.

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2017-03-15)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 3.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。