Skip to content

Instantly share code, notes, and snippets.

Last active July 1, 2023 14:46
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Fail2ban on Ubuntu Server 20.04


Protect your Ubuntu Server with Fail2ban


apt install -y fail2ban

Check Status Ban

  • Default jail name is sshd
sudo fail2ban-client status sshd

Ban Manually

sudo fail2ban-client -vvv set sshd banip x.x.x.x


fail2ban-client set sshd unbanip x.x.x.x

Default configuration

  • Default retry -> max 5
  • Default jail perido -> 10 m

Create notification to Telegram

  • Configure on /etc/fail2ban/jail.conf add this on existing configurar
action  = iptables[name=SSH, port=22, protocol=tcp]
  • Create script on sudo mkdir /etc/fail2ban/scripts/ then create script -> script
  • Create script on /etc/fail2ban/action.d/ then create script telegram.conf -> script
  • Reference


Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment