奇怪的事情发生了:
通过 systemctl 我无法启动 SSHD:
SERVER:~ # systemctl status sshd
● sshd.service - OpenSSH Daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: disabled)
Active: inactive (dead)
May 29 18:31:38 linux-uw9h systemd[1]: Stopped OpenSSH Daemon.
May 29 18:45:19 SERVER systemd[1]: Stopped OpenSSH Daemon.
May 29 18:48:09 SERVER systemd[1]: Stopped OpenSSH Daemon.
May 29 19:04:23 SERVER systemd[1]: Stopped OpenSSH Daemon.
May 29 19:09:51 SERVER systemd[1]: Stopped OpenSSH Daemon.
May 29 19:11:22 SERVER systemd[1]: Stopped OpenSSH Daemon.
May 29 19:12:53 SERVER systemd[1]: Stopped OpenSSH Daemon.
May 29 19:13:58 SERVER systemd[1]: Stopped OpenSSH Daemon.
May 29 19:15:09 SERVER systemd[1]: Stopped OpenSSH Daemon.
May 29 19:24:41 SERVER systemd[1]: Stopped OpenSSH Daemon.
SERVER:~ #
SERVER:~ # systemctl restart sshd
...它只是挂着
但如果我手动输入“/usr/sbin/sshd”,它就会开始很棒!
问:如何调试这个问题?
SERVER:~ # rpm -qf /usr/sbin/sshd
openssh-7.2p2-74.16.3.x86_64
SERVER:~ # rpm -V openssh-7.2p2-74.16.3.x86_64
SERVER:~ # echo $?
0
SERVER:~ #
- dmesg 说没什么特别的
- /var/log/* 没什么特别的
- Journalctl -xe 没有说什么特别的
- -f openssh 中的 zypper 没有帮助
- 没有 FS 为 100%
- 控制台不显示硬件问题
- 已经重启两次了
- 网络/IP 看起来正常,如果 SSHD 运行就可以工作。
- 尝试“systemctl禁用sshd”并启用它,没有帮助。
就像 systemctl 无法启动它,但手动我可以..
SLES 12.3。
2019 年 5 月 30 日更新:
sshd.service 文件的 cksum 与其他工作节点上的相同:
SERVER:~ # cat /usr/lib/systemd/system/sshd.service
[Unit]
Description=OpenSSH Daemon
After=network.target
[Service]
Type=notify
EnvironmentFile=-/etc/sysconfig/ssh
ExecStartPre=/usr/sbin/sshd-gen-keys-start
ExecStartPre=/usr/sbin/sshd -t $SSHD_OPTS
ExecStart=/usr/sbin/sshd -D $SSHD_OPTS
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=always
TasksMax=infinity
[Install]
WantedBy=multi-user.target
SERVER:~ # ls -lah /usr/lib/systemd/system/sshd.service
-rw-r--r-- 1 root root 361 Jan 30 15:46 /usr/lib/systemd/system/sshd.service
SERVER:~ #
在最坏的情况下,我将不得不每分钟设置一个 cronjob 来检查 sshd,因此如果 systemctl 无法启动它,它就会启动它。
2019 年 5 月 31 日更新:
SERVER:~ # strace systemctl restart sshd
execve("/usr/bin/systemctl", ["systemctl", "restart", "sshd"], [/* 57 vars */]) = 0
brk(0) = 0x562494677000
access("/etc/ld.so.preload", R_OK) = -1 ENOENT (No such file or directory)
open("/etc/ld.so.cache", O_RDONLY|O_CLOEXEC) = 3
fstat(3, {st_mode=S_IFREG|0644, st_size=102550, ...}) = 0
...
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"l\4\1\1H\0\0\0\3\0\0\0\206\0\0\0\1\1o\0!\0\0\0", 24}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"/org/freedesktop/systemd1/job/22"..., 200}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 200
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"l\2\1\0012\0\0\0\4\0\0\0\17\0\0\0\5\1u\0\2\0\0\0", 24}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"\10\1g\0\1o\0\0-\0\0\0/org/freedesktop/sys"..., 58}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 58
sendmsg(3, {msg_name(0)=NULL, msg_iov(2)=[{"l\1\4\0019\0\0\0\3\0\0\0\240\0\0\0\1\1o\0-\0\0\0/org/fre"..., 176}, {"\35\0\0\0org.freedesktop.systemd1.Uni"..., 57}], msg_controllen=0, msg_flags=0}, MSG_DONTWAIT|MSG_NOSIGNAL) = 233
recvmsg(3, 0x7ffc4c442360, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable)
ppoll([{fd=3, events=POLLIN}], 1, {24, 999977000}, NULL, 8) = 1 ([{fd=3, revents=POLLIN}], left {24, 999901280})
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"l\2\1\1\10\0\0\0\5\0\0\0\17\0\0\0\5\1u\0\3\0\0\0", 24}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 24
recvmsg(3, {msg_name(0)=NULL, msg_iov(1)=[{"\10\1g\0\1v\0\0\1b\0\0\0\0\0\0", 16}], msg_controllen=0, msg_flags=MSG_CMSG_CLOEXEC}, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = 16
recvmsg(3, 0x7ffc4c442410, MSG_DONTWAIT|MSG_NOSIGNAL|MSG_CMSG_CLOEXEC) = -1 EAGAIN (Resource temporarily unavailable)
ppoll([{fd=3, events=POLLIN}], 1, NULL, NULL, 8
它就挂在这里......几个小时后按 CTRL+C 编辑它。 sshd 不是通过 systemctl 启动的,只能手动启动,奇怪
答案1
您可以尝试使用自己编写的sshd.service
文件来测试它,将其放入/etc/systemd/system
并调用它my-ssh.service
并使用此内容
# /usr/lib/systemd/system/sshd.service
[Unit]
Description=OpenSSH server daemon
After=network.target
[Service]
Type=notify
#EnvironmentFile=-/etc/sysconfig/sshd
#ExecStart=/usr/sbin/sshd -D $OPTIONS $CRYPTO_POLICY
ExecStart=/usr/sbin/sshd -Dd
ExecReload=/bin/kill -HUP $MAINPID
KillMode=process
Restart=on-failure
RestartSec=42s
[Install]
WantedBy=multi-user.target
我从我的 Fedora 站之一获取了上述服务,并替换了 ExecStart 并添加了-d
调试功能。创建一个名为的文件/etc/systemd/system/my-ssh.service
,并将上面的代码片段放入其中,然后使用以下命令重新加载 systemd
systemctl daemon-reload
然后尝试运行该服务
systemctl start my-ssh ; journalctl -f --unit=my-ssh
并查找日志journalctl -f --unit=my-ssh