Created
January 18, 2022 05:36
-
-
Save prolifel/c1ac56608e618bdd946a69a03b802098 to your computer and use it in GitHub Desktop.
Simple fail2ban script for your server. Props: maxretry=3, bantime=7200
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
sudo apt-get update && sudo apt-get install fail2ban -y | |
i=1; | |
ports=""; | |
for port in "$@" | |
do | |
if [ "$ports" = "" ]; | |
then | |
ports=${port} | |
else | |
ports+=",${port}" | |
fi | |
done | |
sudo bash -c 'echo "[sshd] | |
enabled = true | |
port = ${ports} | |
filter = sshd | |
logpath = /var/log/auth.log | |
maxretry = 3 | |
bantime = 7200 " > /etc/fail2ban/jail.local' | |
sudo service fail2ban restart | |
sudo service fail2ban status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment