修改SSH默认的端口后保存 systemctl restart sshd.service后直接失败

Redirecting to /bin/systemctl restart sshd.service
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 ssh]# systemctl status sshd.service
● 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 Wed 2020-11-04 03:27:12 EST; 16s ago
Docs: man:sshd(8)
man:sshd_config(5)
Process: 25665 ExecStart=/usr/sbin/sshd -D $OPTIONS (code=exited, status=255)
Main PID: 25665 (code=exited, status=255)

Nov 04 03:27:12 localhost.localdomain systemd[1]: sshd.service: main process exited, code=exited, status.../n/a
Nov 04 03:27:12 localhost.localdomain systemd[1]: Failed to start OpenSSH server daemon.
Nov 04 03:27:12 localhost.localdomain systemd[1]: Unit sshd.service entered failed state.
Nov 04 03:27:12 localhost.localdomain systemd[1]: sshd.service failed.

sshd -t 没有回馈
完全没有有用的信息,突然想起来selinux这个鬼东西没处理。。。

临时关闭SELinux

setenforce 0

临时打开SELinux

setenforce 1

永久关闭的话,请修改/etc/selinux/config文件,将SELINUX=enforcing修改为disabled
Centos7修改ssh默认端口无法启动sshd服务_重新启动

关闭后再重新启动sshd就没有报错了。

[root@localhost ssh]# systemctl restart sshd
[root@localhost ssh]#