重启服务的时候有如下提示:
[root@localhost ~]# systemctl restart sshd
Job for sshd.service failed because the control process exited with error code. See "systemctl status sshd.service" and "journalctl -xe" for details.
查看状态,查看报错原因
[root@localhost ~]# systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: activating (auto-restart) (Result: exit-code) since 三 2021-05-19 10:21:12 CST; 16s ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 60471 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=255)
Main PID: 60471 (code=exited, status=255)
5月 19 10:21:12 localhost.localdomain systemd[1]: Starting OpenSSH server daemon...
5月 19 10:21:12 localhost.localdomain systemd[1]: sshd.service: main process exited, code=exi.../a
5月 19 10:21:12 localhost.localdomain systemd[1]: Failed to start OpenSSH server daemon.
5月 19 10:21:12 localhost.localdomain systemd[1]: Unit sshd.service entered failed state.
5月 19 10:21:12 localhost.localdomain systemd[1]: sshd.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
只需要执行setenforce 0 随后重启就可以了
[root@localhost ~]# setenforce 0
[root@localhost ~]# systemctl restart sshd
[root@localhost ~]# systemctl status sshd
● sshd.service - OpenSSH server daemon
Loaded: loaded (/usr/lib/systemd/system/sshd.service; enabled; vendor preset: enabled)
Active: active (running) since 三 2021-05-19 10:21:38 CST; 2s ago
Docs: man:sshd(8)
man:sshd_config(5)
Main PID: 60543 (sshd)
Tasks: 1
CGroup: /system.slice/sshd.service
└─60543 /usr/sbin/sshd -D
5月 19 10:21:38 localhost.localdomain systemd[1]: Starting OpenSSH server daemon...
5月 19 10:21:38 localhost.localdomain sshd[60543]: Server listening on 0.0.0.0 port 8888.
5月 19 10:21:38 localhost.localdomain sshd[60543]: Server listening on :: port 8888.
5月 19 10:21:38 localhost.localdomain systemd[1]: Started OpenSSH server daemon.