简介:本文将指导您在CentOS 7上修改SSH端口,以增强系统的安全性。通过简单的步骤,您将能够更改默认的22端口,以减少潜在的安全风险。
在CentOS 7上修改SSH端口需要按照以下步骤进行操作:
/etc/ssh/sshd_config。您可以使用文本编辑器(如vi或nano)进行编辑。例如,使用vi编辑器打开文件:
vi /etc/ssh/sshd_config
将其修改为新的端口号,例如:
#Port 22
Port 23
:wq保存并退出。
systemctl restart sshd
firewall-cmd --zone=public --add-port=23/tcp --permanent
firewall-cmd --reload
b. 使用semanage命令添加新端口:
yum install policycoreutils-python
c. 查询当前SSH服务端口:
semanage port -a -t ssh_port_t -p tcp 23
这将显示当前开放的SSH端口,包括您刚刚添加的23端口。如果新端口未显示在列表中,请重复上述步骤。
semanage port -l | grep ssh