即使在 systemctl enable sshd.service 之后,Fedora 36 上的 SSHd 也无法在启动后启动

即使在 systemctl enable sshd.service 之后,Fedora 36 上的 SSHd 也无法在启动后启动

当我启动我的桌面时,sshd 没有运行:

=$ systemctl status sshd.service
○ sshd.service - OpenSSH server daemon
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: disabled)
     Active: inactive (dead)
       Docs: man:sshd(8)
             man:sshd_config(5)

如果我这样做,sudo systemctl enable sshd.service; sudo systemctl start sshd.service它会毫无问题地上线并且状态显示:

=$ sudo systemctl status sshd.service
● sshd.service - OpenSSH server daemon
     Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: disabled)
     Active: active (running) since Tue 2022-10-25 12:25:47 CEST; 1min 11s ago
       Docs: man:sshd(8)
             man:sshd_config(5)
   Main PID: 14091 (sshd)
      Tasks: 1 (limit: 76311)
     Memory: 2.3M
        CPU: 8ms
     CGroup: /system.slice/sshd.service
             └─ 14091 "sshd: /usr/sbin/sshd -D [listener] 0 of 10-100 startups"
 
Oct 25 12:25:47 orange.home.depesz.com systemd[1]: Starting sshd.service - OpenSSH server daemon...
Oct 25 12:25:47 orange.home.depesz.com sshd[14091]: Server listening on 0.0.0.0 port 22.
Oct 25 12:25:47 orange.home.depesz.com sshd[14091]: Server listening on :: port 22.
Oct 25 12:25:47 orange.home.depesz.com systemd[1]: Started sshd.service - OpenSSH server daemon.

但下次重启时它仍然处于关闭状态。

journalctl | grep sshd.service《没有表现出任何坏处》的最后几行:

Oct 18 11:45:20 orange.home.depesz.com sudo[4936]:   depesz : TTY=pts/1 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl enable sshd.service
Oct 18 11:45:27 orange.home.depesz.com sudo[5039]:   depesz : TTY=pts/1 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl start sshd.service
Oct 18 11:45:28 orange.home.depesz.com systemd[1]: Starting sshd.service - OpenSSH server daemon...
Oct 18 11:45:28 orange.home.depesz.com systemd[1]: Started sshd.service - OpenSSH server daemon.
Oct 18 11:51:40 orange.home.depesz.com systemd[1]: Stopping sshd.service - OpenSSH server daemon...
Oct 18 11:51:41 orange.home.depesz.com systemd[1]: sshd.service: Deactivated successfully.
Oct 18 11:51:41 orange.home.depesz.com systemd[1]: Stopped sshd.service - OpenSSH server daemon.
Oct 18 11:56:37 orange.home.depesz.com sudo[3079]:   depesz : TTY=pts/1 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl enable sshd.service
Oct 18 11:56:40 orange.home.depesz.com sudo[3114]:   depesz : TTY=pts/1 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl start sshd.service
Oct 18 11:56:40 orange.home.depesz.com systemd[1]: Starting sshd.service - OpenSSH server daemon...
Oct 18 11:56:40 orange.home.depesz.com systemd[1]: Started sshd.service - OpenSSH server daemon.
Oct 18 11:56:49 orange.home.depesz.com systemd[1]: Stopping sshd.service - OpenSSH server daemon...
Oct 18 11:56:49 orange.home.depesz.com systemd[1]: sshd.service: Deactivated successfully.
Oct 18 11:56:50 orange.home.depesz.com systemd[1]: Stopped sshd.service - OpenSSH server daemon.
Oct 18 11:57:18 orange.home.depesz.com systemd[1]: Starting sshd.service - OpenSSH server daemon...
Oct 18 11:57:18 orange.home.depesz.com systemd[1]: Started sshd.service - OpenSSH server daemon.
Oct 18 12:26:50 orange.home.depesz.com systemd[1]: Stopping sshd.service - OpenSSH server daemon...
Oct 18 12:26:50 orange.home.depesz.com systemd[1]: sshd.service: Deactivated successfully.
Oct 18 12:26:50 orange.home.depesz.com systemd[1]: Stopped sshd.service - OpenSSH server daemon.
Oct 18 12:31:42 orange.home.depesz.com systemd[1]: Starting sshd.service - OpenSSH server daemon...
Oct 18 12:31:42 orange.home.depesz.com systemd[1]: Started sshd.service - OpenSSH server daemon.
Oct 18 12:51:31 orange.home.depesz.com systemd[1]: Stopping sshd.service - OpenSSH server daemon...
Oct 18 12:51:31 orange.home.depesz.com systemd[1]: sshd.service: Deactivated successfully.
Oct 18 12:51:31 orange.home.depesz.com systemd[1]: Stopped sshd.service - OpenSSH server daemon.
Oct 18 13:30:04 orange.home.depesz.com baloo_file_extractor[3719]: kf.baloo: "/home/depesz/tmp/old-orange/var/lib/systemd/deb-systemd-helper-enabled/sshd.service" id seems to have changed. Perhaps baloo was not running, and this file was deleted + re-created
Oct 18 17:02:51 orange.home.depesz.com sudo[41862]:   depesz : TTY=pts/5 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl start sshd.service
Oct 18 17:02:51 orange.home.depesz.com systemd[1]: Starting sshd.service - OpenSSH server daemon...
Oct 18 17:02:51 orange.home.depesz.com systemd[1]: Started sshd.service - OpenSSH server daemon.
Oct 19 14:02:24 orange.home.depesz.com systemd[1]: Stopping sshd.service - OpenSSH server daemon...
Oct 19 14:02:24 orange.home.depesz.com systemd[1]: sshd.service: Deactivated successfully.
Oct 19 14:02:24 orange.home.depesz.com systemd[1]: Stopped sshd.service - OpenSSH server daemon.
Oct 19 14:02:24 orange.home.depesz.com systemd[1]: sshd.service: Consumed 1.732s CPU time.
Oct 19 14:05:10 orange.home.depesz.com systemd[1]: Starting sshd.service - OpenSSH server daemon...
Oct 19 14:05:10 orange.home.depesz.com systemd[1]: Started sshd.service - OpenSSH server daemon.
Oct 23 10:25:58 orange.home.depesz.com systemd[1]: Starting sshd.service - OpenSSH server daemon...
Oct 23 10:25:58 orange.home.depesz.com systemd[1]: Started sshd.service - OpenSSH server daemon.
Oct 24 20:57:45 orange.home.depesz.com systemd[1]: Stopping sshd.service - OpenSSH server daemon...
Oct 24 20:57:45 orange.home.depesz.com systemd[1]: sshd.service: Deactivated successfully.
Oct 24 20:57:45 orange.home.depesz.com systemd[1]: Stopped sshd.service - OpenSSH server daemon.
Oct 24 20:57:45 orange.home.depesz.com systemd[1]: sshd.service: Consumed 2.378s CPU time.
Oct 25 07:50:08 orange.home.depesz.com sudo[8157]:   depesz : TTY=pts/10 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl enable sshd.service
Oct 25 07:50:10 orange.home.depesz.com sudo[8275]:   depesz : TTY=pts/10 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl start sshd.service
Oct 25 07:50:10 orange.home.depesz.com systemd[1]: Starting sshd.service - OpenSSH server daemon...
Oct 25 07:50:10 orange.home.depesz.com systemd[1]: Started sshd.service - OpenSSH server daemon.
Oct 25 11:44:24 orange.home.depesz.com systemd[1]: Stopping sshd.service - OpenSSH server daemon...
Oct 25 11:44:24 orange.home.depesz.com systemd[1]: sshd.service: Deactivated successfully.
Oct 25 11:44:24 orange.home.depesz.com systemd[1]: Stopped sshd.service - OpenSSH server daemon.
Oct 25 12:25:37 orange.home.depesz.com sudo[13952]:   depesz : TTY=pts/2 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl enable sshd.service
Oct 25 12:25:47 orange.home.depesz.com sudo[14088]:   depesz : TTY=pts/2 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl start sshd.service
Oct 25 12:25:47 orange.home.depesz.com systemd[1]: Starting sshd.service - OpenSSH server daemon...
Oct 25 12:25:47 orange.home.depesz.com systemd[1]: Started sshd.service - OpenSSH server daemon.
Oct 25 12:26:30 orange.home.depesz.com sudo[14226]:   depesz : TTY=pts/2 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/journalctl _SYSTEMD_UNIT=sshd.service
Oct 25 12:26:58 orange.home.depesz.com sudo[14388]:   depesz : TTY=pts/2 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl status sshd.service
Oct 25 12:27:48 orange.home.depesz.com systemd[1]: Stopping sshd.service - OpenSSH server daemon...
Oct 25 12:27:48 orange.home.depesz.com systemd[1]: sshd.service: Deactivated successfully.
Oct 25 12:27:48 orange.home.depesz.com systemd[1]: Stopped sshd.service - OpenSSH server daemon.
Oct 25 12:40:37 orange.home.depesz.com sudo[7448]:   depesz : TTY=pts/1 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl status sshd.service
Oct 25 12:40:48 orange.home.depesz.com sudo[7604]:   depesz : TTY=pts/1 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl status sshd.service
Oct 25 12:40:54 orange.home.depesz.com sudo[7672]:   depesz : TTY=pts/1 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl status sshd.service
Oct 25 12:41:15 orange.home.depesz.com sudo[7772]:   depesz : TTY=pts/1 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/systemctl status sshd.service
Oct 25 12:41:49 orange.home.depesz.com sudo[7988]:   depesz : TTY=pts/1 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/journalctl _SYSTEMD_UNIT=sshd.service
Oct 25 12:42:20 orange.home.depesz.com sudo[8147]:   depesz : TTY=pts/1 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/journalctl _SYSTEMD_UNIT=sshd.service -n 100
Oct 25 12:42:25 orange.home.depesz.com sudo[8214]:   depesz : TTY=pts/1 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/journalctl _SYSTEMD_UNIT=sshd.service -n 50
Oct 25 12:42:28 orange.home.depesz.com sudo[8286]:   depesz : TTY=pts/1 ; PWD=/home/depesz ; USER=root ; COMMAND=/usr/bin/journalctl _SYSTEMD_UNIT=sshd.service -n 50

关于如何修复/调试它有什么想法吗?

啊,最后要说的是 - 重启后 :22 上没有任何监听。我可以使用以下命令毫无问题地启动 sshd.servicesystemctl start sshd.service

答案1

您的日志显示正在sshd.service被主动停用,例如这里:

Oct 25 12:27:48 orange.home.depesz.com systemd[1]: sshd.service: Deactivated successfully.

因此某人或某物正在做sudo systemctl disable sshd.service,从而指示在下次系统启动时systemd不要启动。sshd

您需要调查是谁或什么做了这件事,并相应地予以解决。

相关内容