Harden SSH on a server
Read a server's log full of password guesses, then turn off root login and password sign-in, test the settings before reloading, and add fail2ban so repeat guessers are banned.
What you will do
7 tasks1.Read who is knocking
You are on jump01, a server people sign in to over SSH.
2.Count the attempts on root
Count how many guesses were made against the root account: sudo grep -c "Failed password for root" /var/log/auth.log.
3.Check your key works first
Before passwords are turned off, make sure you have another way in.
4.Turn off root login
People should sign in as themselves and use sudo.
5.Turn off password sign-in
Keys cannot be guessed the way passwords can.
6.Test, then reload
A mistake in this file can lock everyone out.
7.Ban repeat offenders
Install fail2ban, which watches the log and bans addresses that keep failing: sudo apt install -y fail2ban.