CentOS7修改sshd端口

因安全检查要求,需将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 ssh
ssh_port_t                     tcp      22

添加6802端口

semanage port -a -t ssh_port_t -p tcp 6802

验证6802已添加

semanage port -l |grep ssh
ssh_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/tcp
yes

关闭防火墙命令:

systemctl disable firewalld
systemctl stop firewalld

4.重启sshd。

systemctl restart sshd

转载于:https://my.oschina.net/u/3499376/blog/910262

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值