CentOS 7.5 modify the sshd port with SElinux and Firewalld Service running

本文介绍了如何安全地将SSH服务端口从默认的22端口修改为1022。首先,使用Selinux Policy Management tool添加新的端口类型。接着,编辑`/etc/ssh/sshd_config`文件,将端口改为1022。然后,重启sshd服务。随后,打开防火墙对应端口,并更新防火墙规则。最后,验证防火墙设置是否生效。
摘要由CSDN通过智能技术生成

Goal:modify the sshd service port from 22 to 1022.

1. modify the port type

-- Selinux Policy Management tool
-- modify the port type
# semanage port -a -t ssh_port_t -p tcp 1022

2. modify the sshd service port

# vi /etc/ssh/sshd_config
port 1022

3. Restart sshd Service

# systemctl restart sshd.service

4. open firewalld port

# firewall-cmd --zone=public --add-port=22/tcp --permanent
# firewall-cmd --reload

5. display policy

# firewall-cmd --zone=public --list-ports
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值