因安全检查要求,需将sshd端口由22更改为6802。1.修改sshd_config,将Port 22更改为6802[root@localhost ~]# vi /etc/ssh/sshd_confi
因安全检查要求,需将sshd端口由22更改为6802。
1.修改sshd_config,将Port 22更改为6802
[root@localhost ~]# vi /etc/ssh/sshd_config # If you want to change the port on a SELinux system, you have to tell# SELinux about this change.# semanage port -a -t ssh_port_t -p tcp #PORTNUMBER#Port 6802#AddressFamily any#ListenAddress 0.0.0.0#ListenAddress ::
或者
echo 'Port 6802' >> /etc/ssh/sshd_config
2.利用semanage工具,添加6802端口到SELinux。
CentOS默认安装没有semanage工具,需安装
yum install policycoreutils-python
查看sshd原有端口
semanage port -l |grep sshssh_port_t tcp 22
添加6802端口
semanage port -a -t ssh_port_t -p tcp 6802
验证6802已添加
semanage port -l |grep sshssh_port_t tcp 6802, 22
3.因CentOS默认防火墙只开启了22端口,需在防火墙放开6802端口或关闭防火墙。
防火墙放开6802端口命令:
firewall-cmd --zone=public --add-port=6802/tcp
查看6802端口打开状况
[root@localhost ~]# firewall-cmd --query-port=6802/tcpyes
关闭防火墙命令:
systemctl disable firewalldsystemctl stop firewalld
4.重启sshd。
systemctl restart sshd