As root user install:
aptitude install fail2ban python3-systemd
Edit jail.local:
nano /etc/fail2ban/jail.local
Add the following configuration in the sshd section:
[sshd]enabled = trueport = sshlogpath = %(sshd_log)sbackend = systemd
Finally:
systemctl start fail2ban