【linux】在CentOS7上更改ss端口号时报错:Job for sshd.service failed because the control process exited with error

问题描述

在CentOS7上更改ssh端口号时报错:

Job for sshd.service failed because the control process exited with error code.See “systemctl status sshd.service” and “journalctl -xe” for details.

【linux】在CentOS7上更改ss端口号时报错:Job for sshd.service failed because the control process exited with error_第1张图片

原因分析

使用这个下面命令 查看SElinux允许的ssh的端口号

semanage port -l | grep ssh

【linux】在CentOS7上更改ss端口号时报错:Job for sshd.service failed because the control process exited with error_第2张图片
如果提示未安装

  -bash: semanage: command not found

开始安装semanage

  yum provides semanage

【linux】在CentOS7上更改ss端口号时报错:Job for sshd.service failed because the control process exited with error_第3张图片

yum install policycoreutils-python -y

【linux】在CentOS7上更改ss端口号时报错:Job for sshd.service failed because the control process exited with error_第4张图片
安装完成后继续查看semanage 端口
在这里插入图片描述
发现SELinux允许的ssh的端口号和ssh配置文件中设置的端口号不一致。

解决方法

使用semanage工具添加ssh端口号

semanage port -a -t ssh_port_t -p tcp 17031

【linux】在CentOS7上更改ss端口号时报错:Job for sshd.service failed because the control process exited with error_第5张图片
重启
在这里插入图片描述

你可能感兴趣的:(Linux)