CenterOS7 修改 SSH 端口
首先修改 /etc/ssh/sshd_config 文件中的 Port。修改前一定要备份
可以同时启用多个Port所以最好先追加一个端口,新端口校验没问题之后再把原端口删除
防火墙设置
# 永久开放端口
sudo firewall-cmd --zone=public --add-port=3000/tcp --permanent
# 重新加载文件
sudo firewall-cmd --reload
# 永久关闭端口
sudo firewall-cmd --remove-port=3000/tcp --permanent
# 关闭防火墙
sudo systemctl stop firewalld
修改端口号之后,重启sshd服务一直无法成功,把selinux关闭就行了
# 临时关闭
setenforce 0
# 临时打开
setenforce 1
# 永久关闭修改 /etc/selinux/config文件
# This file controls the state of SELinux on the system.
# SELINUX= can take one of these three values:
# enforcing - SELinux security policy is enforced.
# permissive - SELinux prints warnings instead of enforcing.
# disabled - No SELinux policy is loaded.
#### 修改这个位置 SELINUX 为 disabled 禁用 enforcing 启用
SELINUX=enforcing
####
# SELINUXTYPE= can take one of three values:
# targeted - Targeted processes are protected,
# minimum - Modification of targeted policy. Only selected processes are protected.
# mls - Multi Level Security protection.
SELINUXTYPE=targeted

浙公网安备 33010602011771号