Port PORT LogLevel INFO LoginGraceTime 20 PermitRootLogin no MaxAuthTries 3 PubkeyAuthentication yes PasswordAuthentication no PermitEmptyPasswords no KerberosAuthentication no GSSAPIAuthentication no AllowAgentForwarding no AllowTcpForwarding no X11Forwarding no PermitUserEnvironment no ClientAliveInterval 300 ClientAliveCountMax 2 PermitTunnel no ChallengeResponseAuthentication no DebianBanner no Protocol 2
Run sudo systemctl restart sshd to make change in effect.
Remember to open specific port in firewall.
Step 6: Setup fail2ban
/etc/fail2ban/jail.d/defaults-debian.conf
[sshd] enabled = true port = PORT filter = sshd logpath = /var/log/auth.log maxretry = 3
Run sudo systemctl enable --now fail2ban to enable fail2ban.