Fail2Ban

Fail2Ban is an intrusion prevention software framework that protects computer servers from brute-force attacks. Written in the Python programming language, it is able to run on POSIX systems that have an interface to a packet-control system or firewall, for example, iptables or TCP Wrapper.
Software Installation
fail2ban is available as package in the Ubuntu software repository.
$ sudo apt update
$ sudo apt install fail2ban
After Installation the service is not enabled:
$ sudo systemctl enable fail2ban.service
Default configuration will ban failed SSH logins, if Firewall is enabled.