centos8安装完系统后,修改了sshd.config的端口信息,于是执行了systemctl restart sshd.service,可是提示Job for sshd.service failed because the control process exited with error。想了想,估计是sshd.service没启动,查看sshd.service就是没有启动,可是也启动不起来。
1、查看SElinux允许的ssh的端口号
$ sudo semanage port -l | grep ssh
ssh_port_t tcp 22
发现SELinux允许的ssh的端口号和ssh配置文件中设置的端口号不一致。
2、解决方法
使用semanage工具添加ssh端口号
sudo semanage port -a -t ssh_port_t -p tcp 588588
3、重启
sudo systemctl restart sshd.service
总结:sudo +systemctl restart sshd.service就可以恢复了。