Module 2 · Services, SSH and Hardening · Lesson 8 of 10
Guided project: harden an Ubuntu server
Baseline, update, key-only SSH, a UFW firewall that keeps you in, trimmed services, and a reboot test.
In this lesson · about 45 minutes
- Record a baseline before changing anything
- Apply SSH and firewall hardening without losing access
- Prove the result with an access test matrix and a reboot
Whiteboard · watch and try
Whiteboard: the safe order of steps
Press Play. The tutor writes the order that keeps you from locking yourself out.
Tip: press Pause, then use the pen to work along on the board. Space plays and pauses; Ctrl+Z undoes your last mark.
Try it · watch it happen
The firewall is a guard with a guest list
Tick rules and enable the firewall in different orders. Send the visitors and see who gets in. Can you lock yourself out?
The guard's guest list
Default rule: turn away anyone who isn't on the list (deny incoming).
At the gategate wide open
Setup: an Ubuntu VM with OpenSSH and UFW, a second client machine, and a written baseline. Take a snapshot first and keep a console open (the VM's own screen, not SSH) so you can recover if you lock yourself out.
The six steps
- Baseline. Snapshot the VM. Record users, group membership, running services, listening ports and what the host is for.
- Update and separate duties. Apply updates from trusted repositories and check whether a restart is needed. Create a named administrator; do routine work without sudo.
- Key-based SSH. Set up key login, validate the config with
sudo sshd -t, test another session, and only then turn off password and root logins. Check drop-in files in/etc/ssh/sshd_config.d/, which can override the main file. - Firewall. Allow SSH from your real management client IP before enabling UFW. Don't copy an example address without replacing it.
- Trim and watch. Disable only services you've shown are unnecessary. Read logs with
journalctland check AppArmor withsudo aa-status. Never disable a protection just to make an unexplained error go away. - Prove it. Test approved login, denied access from another client, service health, and everything again after a reboot. Save evidence, then remove temporary users or restore the snapshot.
Hands-on lab (simulated terminal)
Project lab: steps 1 to 4
You're admin on ubuntu-lab (10.10.10.5). Your management client is 10.10.10.20. A console session is open as backup. Sudo password: lab.
Step 1 of 9. Type each command and press Enter. Nothing runs on your computer.
1. Step 1 baseline: list listening TCP and UDP ports with processes.
Performance-based question (PBQ)
Step 6: the access test matrix
After rebooting, you ran these tests. Decide whether each result is what a hardened server should do.
Mark each result.
- Key login from 10.10.10.20 works
- SSH from 10.10.10.30 (another lab client) times out
- Password login from 10.10.10.20 says 'Permission denied (publickey)'
- curl http://10.10.10.5 from 10.10.10.30 returns 200 OK
- After reboot, systemctl is-active nginx says inactive
- ssh root@10.10.10.5 from 10.10.10.20 logs in
Noviq Academy is free and for learning. Every terminal here is simulated and every log is synthetic. Practise on a disposable VM with a snapshot, never on a production server. Ubuntu is a trademark of Canonical Ltd.; this course is independent of Canonical.