Linux VPS首次使用简单的安全配置 | 您所在的位置:网站首页 › say英文什么意思怎么读出来 › Linux VPS首次使用简单的安全配置 |
1、如果是CentOS7,默认防火墙是firewalld,则需要关闭firewall,安装iptables,具体如下: 1)关闭firewall: systemctl stop firewalld.service #停止firewall systemctl disable firewalld.service #禁止firewall开机启动 2)安装iptables防火墙 yum install iptables-services 2、修改ssh的端口和配置iptables防火墙 1)用vi 编辑/etc/ssh/sshd_config文件 2)找到#Port 22一段,这里是标识默认使用22端口,修改为如下: Port 22 Port 50000 然后保存退出 3)执行/etc/init.d/sshd restart。现在ssh端口将同时工作与22和50000上(同时两个端口是为了防止发生意外情况导致连不上服务器,等下面测试成功后,在删除22端口)。 4)配置iptables 1)下载脚本 wget -O iptables.sh http://file.aionlife.xyz/source/download?id=5ba663a0dc72d91ff8d539ed 2)执行脚本 bash iptables.sh 5)测试50000端口是否可以正常连接,如果正常则把/etc/ssh/sshd_config中的22端口删除了。 3、禁用root登陆,添加新账户 1)添加新帐户msa(以msa为例,可自己指定帐户名) [root@kvm7 ~]# useradd msa 2)设置msa的密码 [root@kvm7 ~]# passwd msa 输入两次密码就修改完成。 3)修改/etc/ssh/sshd_config文件,禁止使用root用户登陆 vi /etc/ssh/sshd_config 找到#PermitRootLogin yes,去掉前面的#,并将yes改为no,然后重启sshd。 service sshd restart 4)用新建的帐户登陆后,要是需要使用root权限,则使用su root进行切换用户或者sudo后加要执行的命令。 4、安装DDos deflate防御轻量级CC和DDOS,这个主要防止别人恶意请求你的vps。 1)软件需要用iptables,使用下面命令查看iptables防火墙状态,也确认一下服务器中否安装iptables。 service iptables staus 2)安装DDos deflate wget -O install.sh http://file.aionlife.xyz/source/download?id=5ba66498dc72d91ff8d539ee chmod +x install.sh ./install.sh 3)修改/usr/local/ddos/ddos.conf配置文件,使得iptables可以自己自动锁定ip。 ##### Paths of the script and other filesPROGDIR=”/usr/local/ddos”PROG=”/usr/local/ddos/ddos.sh”IGNORE_IP_LIST=”/usr/local/ddos/ignore.ip.list” //IP地址白名单CRON=”/etc/cron.d/ddos.cron” //定时执行程序APF=”/etc/apf/apf”IPT=”/sbin/iptables”##### frequency in minutes for running the script##### Caution: Every time this setting is changed, run the script with –cron##### option so that the new frequency takes effectFREQ=1 //检查时间间隔,默认1分钟##### How many connections define a bad IP? Indicate that below.NO_OF_CONNECTIONS=150 //最大连接数,超过这个数IP就会被屏蔽,一般默认即可##### APF_BAN=1 (Make sure your APF version is atleast 0.96)##### APF_BAN=0 (Uses iptables for banning ips instead of APF)APF_BAN=0 //使用APF还是iptables。推荐使用iptables,将APF_BAN的值改为0即可。##### KILL=0 (Bad IPs are’nt banned, good for interactive execution of script)##### KILL=1 (Recommended setting)KILL=1 //是否屏蔽IP,默认即可##### An email is sent to the following address when an IP is banned.##### Blank would suppress sending of [email protected] //当IP被屏蔽时给指定邮箱发送邮件,推荐使用,换成自己的邮箱##### Number of seconds the banned ip should remain in blacklist.BAN_PERIOD=600 //禁用IP时间,默认600秒,可根据情况调整4)手动设置白名单并不可修改 vi /usr/local/ddos/ignore.ip.list #手工设置白名单IPchattr +i /usr/local/ddos/ignore.ip.list #强制不允许修改chattr -i /usr/local/ddos/ignore.ip.list #解除不允许修改 卸载DDos deflate: wget -O uninstall.ddos http://file.aionlife.xyz/source/download?id=5ba66587dc72d91ff8d539ef chmod 700 uninstall.ddos ./uninstall.ddos |
CopyRight 2018-2019 实验室设备网 版权所有 |