#!/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规则
ipta