#!/bin/bash red='\033[0;31m' green='\033[0;32m' yellow='\033[0;33m' plain='\033[0m' cur_dir=$(pwd) # check root [[ $EUID -ne 0 ]] && echo -e "${red}严重错误: ${plain} 请以 root 权限运行此脚本 \n " && exit 1 install_base() { apk add --no-cache --update ca-certificates tzdata fail2ban bash rm -f /etc/fail2ban/jail.d/alpine-ssh.conf cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local sed -i "s/^\[ssh\]$/&\nenabled = false/" /etc/fail2ban/jail.local sed -i "s/^\[sshd\]$/&\nenabled = false/" /etc/fail2ban/jail.local sed -i "s/#allowipv6 = auto/allowipv6 = auto/g" /etc/fail2ban/fail2ban.conf } gen_random_string() { local length="$1" local random_string=$(LC_ALL=C tr -dc 'a-zA-Z0-9'