威力惊人

贴个部署教程

# 安装fail2banapt install -y fail2ban# 编写配置tee /etc/fail2ban/jail.d/sshd.local > /dev/null <<'EOF'[sshd]enabled  = trueport     = sshfilter   = sshd# 通过systemd获取错误登录backend  = systemd# 3 次失败maxretry = 3# 在 6000 秒(1 小时)内findtime = 6000# 封禁 3600 秒(1 小时);可用 'bantime = -1' 永久封禁bantime  = -1	# 白名单(本机、运维 IP)ignoreip = 127.0.0.1/8action = iptables-multiport[name=sshd, port="ssh", protocol=tcp]EOF# 开启自启动systemctl enable --now fail2ban# 重启 fail2bansystemctl restart fail2ban# 查看状态fail2ban-client status # 查看 sshd jail 具体信息(被封的 IP 列表)fail2ban-client status sshd