Step 6 of 7 · lab · 30 min
The brute force goes on
Someone on the neighbouring machine keeps trying to log in to the server's SSH. fail2ban is installed and running, a colleague has even tuned it, and still there is no ban. Find out why and make sure the attacker gets banned and the administrator never does.
Situation
Someone on node2 keeps trying to log in to node1's SSH: every twenty seconds there are new attempts under
made-up user names. They show up in the login journal: sudo journalctl -u ssh -f. node1 has fail2ban for exactly
this: the service is enabled and running, the sshd jail is started, and last week a colleague went over its
settings once more. node2 has still not been banned.
The administrator's laptop admin-pc (its address: getent hosts admin-pc) logs in to node1 every day and
sometimes gets the login wrong. fail2ban must not ban that address.
node1 is your terminal; reach node2 with ssh node2. sudo works without a password on both machines.
Task
- node2's address is banned by the
sshdjail:sudo fail2ban-client status sshdlists it, and node1's SSH is closed to node2. - Any other address on the network gets banned by itself after five failed SSH logins within ten minutes, with no manual commands.
- The jail skips failed logins from
admin-pc, and that address does not get banned. - The settings are saved in the
/etc/fail2banfiles: aftersudo systemctl restart fail2banthe jail works the same. The fail2ban service is enabled.
The lab has no internet access, only the network between node1 and node2. Everything you need is installed on both machines. There is no need to stop the attacker on node2: the task is in fail2ban on node1.
Lab · on your own
No commands are given in this lab: type them in the terminal yourself. Goals are checked on the machine after every command.
Goals
0 of 4-
node2's address is banned by the sshd jail — node1's SSH is closed to node2 — not done yet
-
A new address on the network gets banned by itself after five failed SSH logins — not done yet
-
The jail skips failed logins from admin-pc and does not ban it — not done yet
-
The settings are saved in /etc/fail2ban — after fail2ban restarts the jail works the same; the service is enabled — not done yet
The machine is starting
Hints
0 of 3Lab goals
0 of 4-
node2's address is banned by the sshd jail — node1's SSH is closed to node2 — not done yet
-
A new address on the network gets banned by itself after five failed SSH logins — not done yet
-
The jail skips failed logins from admin-pc and does not ban it — not done yet
-
The settings are saved in /etc/fail2ban — after fail2ban restarts the jail works the same; the service is enabled — not done yet
Goals are checked on the machine after every command.