fail2ban安装epel CentOS7 1wget -O /etc/yum.repos.d/epel.repo http://mirrors.aliyun.com/repo/epel-7.repo CentOS8 123yum install -y https://mirrors.aliyun.com/epel/epel-release-latest-8.noarch.rpmsed -i 's|^#baseurl=https://download.example/pub|baseurl=https://mirrors.aliyun.com|' /etc/yum.repos.d/epel*sed -i 's|^metalink|#metalink|' /etc/yum.repos.d/epel* 安装fail2ban12345678910111213141516yum install -y fail2bancp /etc/fail2ban/jail.conf /etc/fail2ban/jail.localcat <<EOF > /etc/fail2ban/jail.local[ssh-iptables] ignoreip = 127.0.0.1/8 192.168.1.0/24 enabled = true filter = sshd action = iptables[name=SSH, port=22, protocol=tcp] logpath = /var/log/secure maxretry = 3 findtime = 300 EOFsystemctl enable --now fail2ban 使用fail2ban12345678# 查看ssh-iptables状态fail2ban-client status ssh-iptables# 取消IP banfail2ban-client set ssh-iptables unbanip 23.34.45.56# IP banfail2ban-client set ssh-iptables banip 23.34.45.56