# centos8修改22端口

# 1. 修改 /etc/ssh/sshd_config

vim /etc/ssh/sshd_config

#Port 22
#AddressFamily any
#ListenAddress 0.0.0.0
#ListenAddress ::

Port 2222   # 添加此配置
1
2
3
4
5
6
7
8

# 2. 重启sshd服务

systemctl restart sshd.service    # 重启sshd服务让配置文件生效
1

# 3. 防火墙开放2222端口

firewall-cmd --zone=public --add-ports=2222/tcp --permanent     # 添加规则
firewall-cmd --reload                                           # 重新加载防火墙配置
firewall-cmd --list-ports                                       # 查看已开放的端口
1
2
3
更新时间: 2021-06-07 15:34:00