Fail2Ban

Based off this tutorial.

Install

sudo apt update && sudo apt install fail2ban

Configure

Copy and edit the configuration file:

sudo cp /etc/fail2ban/jail.{conf,local} && sudo nano /etc/fail2ban/jail.local

Uncomment and add IP:

ignoreip = 127.0.0.1/8 ::1 192.168.1.0/24

Change ban time:

bantime = 1d

Update sshd section:

[sshd]
enabled   = true
maxretry  = 3
findtime  = 1d
bantime   = 4w
ignoreip  = 127.0.0.1/8

Then sudo systemctl restart fail2ban.

Check Status

Find status of specific service, like sshd:

sudo fail2ban-client status sshd

Show all options:

fail2ban-client -h

Unban

Unban IP with set [jailname] unbanip:

sudo fail2ban-client set bitwarden_rs unbanip 192.168.1.244