Blocking brute-force attacks with Fail2Ban
Automatically ban IPs that keep failing to log in.
apt install -y fail2ban
cat > /etc/fail2ban/jail.local <<'EOF'
[sshd]
enabled = true
maxretry = 5
bantime = 1h
EOF
systemctl enable --now fail2ban
fail2ban-client status sshdTo unban an address (for example your own):
fail2ban-client set sshd unbanip 198.51.100.7SSH keys with password login turned off make brute-force attempts useless. See First steps with a new server.