← System admin on a Raspberry Pi

Challenge: the class server

Set up the Pi as the class server: a hand-in share, accounts in one group, a firewall that lets only the right ports through, and a nightly backup. Then explain what each part protects, and what it does not.

Your class gets one Pi. By Friday it has to be a safe place to hand in work. Where do you start?

This is the whole of the course in one job. Each part covers a different risk: accounts and groups decide who, permissions decide what, the firewall decides which doors, the backup covers what if it breaks. No one part is enough on its own. This also covers AC9TDI10K01's last idea: how several components together secure a networked system.

How this lesson works: Predict, Try, Investigate, Modify, Practise, Make
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.

Firewall order

You are logged in to the Pi over ssh. You type sudo ufw enable first, planning to add the ssh rule next. What happens?

TryTry it on the board and compare the result with your prediction.

Try: the safe order

Was your prediction right?

Try it yourselfYour edits are saved in this browser.

Log in with ssh pi@raspberrypi.local, allow ssh with sudo ufw allow ssh, and only then enable the firewall: sudo ufw enable.

Use the board. This ticks when you get there.

InvestigateWork out why it happens, one step at a time.

Worked example: Layers, not one lock

Worked exampleBefore each step, say what you think comes next.
  1. accounts and groups\text{accounts and groups}who is allowed (lesson 3).

Now try it yourself.

Which part protects against 'a file is deleted by mistake'?

Sam is locked out. Click the line where it first goes wrong.

Which is safer for watching Jellyfin away from school: opening port 8096 on the router, or a VPN such as Tailscale or WireGuard?

ModifyChange the problem on purpose and see what happens.

Vary: change one thing

Try it yourselfYour edits are saved in this browser.

Install samba and jellyfin.

Use the board. This ticks when you get there.

Turn the firewall on so that only Jellyfin's port 8096 gets through (and ssh).

Use the board. This ticks when you get there.

smbd runs but is not enabled. Make it survive a reboot, reboot, and check it is up.

Use the board. This ticks when you get there.

PractiseA few on your own, to check you have it.

Practise

Which two layers together mean 'only class members may save files, and only from the school network'?

Which is the weakest protection for a share?

A student asks to open a router port so they can reach the Pi from home. What is the best first answer?

MakeMake your own problem using what you have learned. Expect a few tries; that is normal.

The class server

Then write up your server: for each part, what it protects against and what it does not. That is the brief for this course.

Try it yourselfYour edits are saved in this browser.
Need a hint?

Before a hint: what kind of stuck is this? Try a strategy first

Five jobs: install samba, share /srv/class to group class, let the group write, open port 445 with the firewall, a nightly backup.

Another hint

sudo apt install samba; add [class] with path = /srv/class using tee; sudo systemctl restart smbd; sudo chgrp class /srv/class; sudo chmod 775 /srv/class.

Another hint

sudo ufw allow ssh; sudo ufw allow 445; sudo ufw enable; echo "30 2 * * * tar -czf /media/usb/class.tar.gz /srv/class" | crontab -

Set up the class server: Samba installed with a [class] share of /srv/class that Alex and Bob (group class) can write to, the firewall on with port 445 reachable, and a backup scheduled at 02:30 every night.

Use the board. This ticks when you get there.

Now you can
Finished the course?Go over it: System admin on a Raspberry Pi recapEvery idea in one place, to check you've got it.You reached the endBack to System admin on a Raspberry Pi
For teachers

Set up the Pi as the class server: a hand-in share, accounts in one group, a firewall that lets only the right ports through, and a nightly backup. Then explain what each part protects, and what it does not. About 40 minutes.

Open the teacher guide: answers, solutions, slides and a worksheet.

Students will be able to

Before class

Try the board yourself; it is the longest Make in the course.

The one idea: several components together secure a networked system, and each covers a different risk. Students should leave able to say, for each layer, what it does not protect: the firewall does not stop a stolen password; permissions do not stop a failed disk; a backup does not stop a leak.

Simplifications: the pretend firewall tracks allow <port> and enable, not source addresses or default policies. The real ufw lets you restrict by network (for example only 192.168.1.0/24) which is what a school would do.

This is the capstone for System admin. Students then complete the brief (an admin log and a short report), which assesses AC9TDI10K01 nodes 3 and 5. If you have a real Pi, setting up the same server on it is a good practical.

A later extension, a lab with Kali Linux on a Pi in an offline network, is planned (roadmap/systems.md); it needs your sign-off and a lab network the school IT team approves.

With internet: automatic updates, off-site backups and a VPN (Tailscale or WireGuard) belong on a server people use from home. A domain name and certificate (Let's Encrypt) matter when a service is public, and so does an honest answer to 'should it be public at all?'

Running the lesson

  1. Predict: wrong answers think the rule can come second.
  2. Try: ask what would have happened in the other order.
  3. Worked example: ask which layer would have stopped each of the 'what if' stories.
  4. Vary: have pairs check each other's work.
  5. Make: ask each pair which layer they would add next.

The hard part (on purpose)

The order of the firewall steps and remembering every layer. Give students a checklist and tick it as they go.

When students get stuck

Stretch and support

Stretch: Add automatic security updates (unattended-upgrades) and say which risk they cover.

Support: A checklist of the five layers.

Where it leads

Links: Networks (ports); Cyber safety and privacy; Security and privacy; The command line.

What each step is for