Peters School of Business · Assiniboine College · NETW-0014
2 hours · fail2ban lab + Written & Practical Assessment · Week 1 close
Classroom setup before students arrive
Install fail2ban, configure an SSH jail, trigger and verify a ban
What fail2ban does
/var/log/auth.log. After a configurable number of failed attempts within a time window, it adds an iptables DROP rule for that source IP.Step 1 — Install and verify (5 min)
sudo apt install fail2ban. Verify it's running: sudo systemctl status fail2ban. Check the default jails that ship with it: sudo fail2ban-client status.Step 2 — Create jail.local (10 min)
jail.conf (default, never edit directly — it gets overwritten on updates) and jail.local (your local overrides — create this). Create the file:
sudo nano /etc/fail2ban/jail.local
[DEFAULT]
bantime = 600
findtime = 300
maxretry = 5
[sshd]
enabled = true
port = 2222
logpath = /var/log/auth.log
maxretry = 5
sudo systemctl restart fail2ban. Verify the sshd jail is active: sudo fail2ban-client status sshd. You should see the jail is active with 0 currently banned IPs.Step 3 — Trigger and verify a ban (15 min)
-o PubkeyAuthentication=no to force password auth). After five failures, further connection attempts should hang or be immediately refused.sudo fail2ban-client status sshd — your Windows host IP should appear in the "Banned IP list". Check the fail2ban log: sudo tail /var/log/fail2ban.log — you should see the ban event with timestamp and banned IP.sudo fail2ban-client set sshd unbanip [your-windows-ip]. Verify you can SSH again. Record the ban and unban log entries in your lab sheet.bantime values (e.g., 60 seconds for faster testing). Have them check iptables -L -n during an active ban to see the DROP rule fail2ban creates.Written portion — SSH theory, sshd_config directives, fail2ban concepts
Pen and paper. No computer, no phone, no notes. 30 minutes. Distribute sheets face-up when instructed.
Section A — Short answer (15 marks)
id_rsa to the server's authorized_keys file. Key auth does not work. Identify the mistake and explain the correct action.AllowUsers directive in sshd_config? Give an example of when you would use it.PasswordAuthentication no in sshd_config but password logins still work. Name two possible reasons why./etc/ssh_banner) and the MOTD (/etc/motd). When does each appear during an SSH connection?Section B — Scenario (10 marks)
PasswordAuthentication yes
PermitRootLogin yes
LoginGraceTime 0
Port 22
bantime = 300, findtime = 60, maxretry = 3. An attacker makes 2 failed attempts, waits 65 seconds, then makes 2 more failed attempts. Is the attacker banned? Explain your reasoning.Practical — diagnose and repair a broken SSH configuration
Students receive access to S1 via the Hyper-V console (no SSH — that's part of what's broken). They must diagnose and repair the SSH configuration so that key-based authentication works, then demonstrate each hardening setting is in place. No notes, no internet. Man pages (man sshd_config, man fail2ban) are allowed.
Practical scenario — instructor setup
PasswordAuthentication yes re-enabled
AllowUsers root (wrong user, locks out the student account)
authorized_keys permissions changed to 644 (key auth silently fails)
Practical tasks (students are graded on these)
fail2ban-client status sshd, then unban the IP and restore access.Mini-Assessment 1 — marking summary
| Component | Format | Weight | Key topics |
|---|---|---|---|
| Written — Section A | Short answer | 15 marks (30%) | Key cryptography, sshd_config directives, fail2ban mechanism, banners |
| Written — Section B | Scenario analysis | 10 marks (30%) | Config vulnerability identification, fail2ban logic, NAT routing requirements |
| Practical — Task 1 | Live demonstration | 15 marks (70%) | Restore key-based SSH access on correct port |
| Practical — Task 2 | Live demonstration | 10 marks (70%) | Verify password auth disabled |
| Practical — Task 3 | Config review | 10 marks (70%) | All hardening directives correctly set |
| Practical — Task 4 | Live demonstration | 15 marks (70%) | fail2ban operational, ban triggered and cleared |