 apt install sudo -y
 apt install fail2ban -y

echo '[DEFAULT]
ignoreip = 127.0.0.1/8
bantime = 1h
[sshd]
enabled = true
# To use more aggressive sshd modes set filter parameter "mode" in jail.local:
# normal (default), ddos, extra or aggressive (combines all).
# See "tests/files/logs/sshd" or "filter.d/sshd.conf" for usage example and details.
#mode   = normal
port    = ssh
logpath = %(sshd_log)s
backend = %(sshd_backend)s
maxretry = 5' >/etc/fail2ban/jail.local


 sudo service fail2ban restart

sudo fail2ban-client ping

sudo fail2ban-client status

sudo fail2ban-client status sshd