CentOS7 修改sshd默认端口为2022,重启sshd结果一直报错 ``
启动了selinux导致
[root@host~]# sestatus SELinux status: enabled SELinuxfs mount: /sys/fs/selinux SELinux root directory: /etc/selinux Loaded policy name: targeted Current mode: enforcing Mode from config file: enforcing Policy MLS status: enabled Policy deny_unknown status: allowed Max kernel policy version: 31 [root@host~]#将新端口加入到 selinux
[root@ip-172-30-0-30 ~]# semanage port -a -t ssh_port_t -p tcp 2022没有semanage,yum安装一个
yum install policycoreutils-python搞好之后,检查一下
[root@ip-172-30-0-30 ~]# semanage port -l | grep ssh ssh_port_t tcp 2022, 22别忘了重启 sshd
systemctl restart sshd参考来源:https://ddewaele.github.io/networking/ssh/changing-the-ssh-port/