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 goals
0 of 4-
node2's address is banned by the sshd jail — node1's SSH is closed to node2 — not checked yet
-
A new address on the network gets banned by itself after five failed SSH logins — not checked yet
-
The jail skips failed logins from admin-pc and does not ban it — not checked yet
-
The settings are saved in /etc/fail2ban — after fail2ban restarts the jail works the same; the service is enabled — not checked yet