一、设置复杂密码
二、开启防火墙,设置指定端口
1、开放端口
先查看下防火墙状态
(0)查看防火墙开启状态
firewall-cmd --state
如果没开启 开启防火墙并设置开机自启
-
systemctl start firewalld
-
systemctl enable firewalld
(1)如我们需要开启XShell连接时需要使用的22端口
firewall-cmd --zone=public --add-port=22/tcp --permanent
其中--permanent的作用是使设置永久生效,不加的话机器重启之后失效
(2)重新载入一下防火墙设置,使设置生效
firewall-cmd --reload
(3)如下命令可查看当前系统打开的所有端口
firewall-cmd --zone=dmz --list-ports
三、ssh ip访问限制
四、ip访问限制
ps:
1、centos出现“FirewallD is not running”怎么办 请查看 :https://www.cnblogs.com/rxbook/p/8110143.html
2、Linux系统通过firewall限制或开放IP及端口 https://blog.csdn.net/ywd1992/article/details/80401630
3、CentOS 7 下使用 Firewall 防火墙 https://www.linuxidc.com/Linux/2018-03/151218.htm