Sshguard is a free and open source software to protect your server from brute-force attacks against SSH and other services on Linux or Unix-like system. It aggregates system logs and blocks repeat offenders using one of several firewall backends, including iptables, ipfw, and pf.
Ubuntu MATE 16.04.2 for Raspberry Pi 2B and 3 devices has disabled SSH by default, but once SSH is enabled by users — it will also enable SSHGuard at the same time. SSHGuard is a small program that adds block rules to the system firewall in response to SSH brute-force login attacks. This is the first Linux distribution to install and enable SSHGuard by default.