版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/u010168781/article/details/88662058
1、问题描述
在在CentOS7上更改端口号时报错:
Job for sshd.service failed because the control process exited with error code.See “systemctl status sshd.service” and “journalctl -xe” for details.
2、修改ssh端口号的方法
修改:$ sudo vi /etc/ssh/sshd_config
将 “#Port 22” 改为 “Port 11234”
将 “#PermitRootLogin yes” 改为 “PermitRootLogin no”
重启:sudo systemctl restart sshd.service
重启后报错
3、原因分析
查看SElinux允许的ssh的端口号
$ sudo semanage port -l | grep ssh
ssh_port_t tcp 22
发现SELinux允许的ssh的端口号和ssh配置文件中设置的端口号不一致。
4、解决方法
使用semanage工具添加ssh端口号
sudo semanage port -a -t ssh_port_t -p tcp 11234
重启
sudo systemctl restart sshd.service