Linux Labs

Server security / Stage 5 of 10 · step 6 of 7

The brute force goes on

medium ~30 min
Not running Starting usually ~20 s
Report a problem

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

  1. node2's address is banned by the sshd jail: sudo fail2ban-client status sshd lists it, and node1's SSH is closed to node2.
  2. Any other address on the network gets banned by itself after five failed SSH logins within ten minutes, with no manual commands.
  3. The jail skips failed logins from admin-pc, and that address does not get banned.
  4. The settings are saved in the /etc/fail2ban files: after sudo systemctl restart fail2ban the 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.

Visible only to you. Saved as you type.

All notes

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

Hints

0 of 3 open · they open one at a time
Hint 1
Show the solution after 3 failed checks

Leave the lab?

The machine keeps running for 10 more minutes, then it is removed. Files are lost; completed goals stay.

Loading…