#!/bin/bash
# 安装常用的软件包
yum install -y epel-release
yum install -y net-tools wget vim telnet
# 关闭不必要的服务
systemctl disable firewalld.service
systemctl stop firewalld.service
systemctl disable NetworkManager.service
systemctl stop NetworkManager.service
systemctl disable postfix.service
systemctl stop postfix.service
# 禁用root用户远程登录
sed -i 's/#PermitRootLogin yes/PermitRootLogin no/' /etc/ssh/sshd_config
systemctl restart sshd
# 安装fail2ban并设置
yum install -y fail2ban
cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
systemctl enable fail2ban
systemctl start fail2ban
# 配置iptables规则
iptables -F
ipta

该脚本执行一系列任务,包括安装常用软件,关闭防火墙和NetworkManager,禁止root用户远程登录,安装fail2ban增强安全性,配置iptables规则以限制输入流量,并更新系统到最新版本。这些步骤构成了初步的服务器安全加固。
最低0.47元/天 解锁文章

580

被折叠的 条评论
为什么被折叠?



