Skip to content

Instantly share code, notes, and snippets.

@doches
Created March 14, 2022 12:46
Show Gist options
  • Save doches/7ce8d27fb094185c3dd71055794b0b04 to your computer and use it in GitHub Desktop.
Save doches/7ce8d27fb094185c3dd71055794b0b04 to your computer and use it in GitHub Desktop.
#!/bin/bash
set -euxo pipefail
dnf install -y fail2ban
systemctl enable fail2ban
cat > /etc/fail2ban/jail.local<< EOF
[DEFAULT]
# Ban hosts for one hour:
bantime = 3600
findtime = 600
maxretry = 3
# Override /etc/fail2ban/jail.d/00-firewalld.conf:
banaction = iptables-multiport
[sshd]
enabled = true
EOF
systemctl restart fail2ban
sleep 2
fail2ban-client status sshd
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment