A computer records every login attempt. A long run of failures for one account from one address in a short time is someone guessing passwords. Reading the log is the defender's view of an attack, and the fix is to make guessing harder, not to hope it fails.
Someone has been trying the target's login. How do you tell, and how bad is it?
What you should already know:
Host Jellyfin, a media server· Jellyfin serves your films and music to any device on the network, through a web page on port 8096.
This is authentication (who are you?) from the defender's side. Every login attempt, good or bad, is written in /var/log/auth.log. Only an administrator can read it, so you log in to the target as the lab's admin account and use sudo. grep picks out lines, and grep -c counts them.
How this lesson works: Predict, Try, Investigate, Modify, Practise, Make
Predict: Read the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
Try: Try it on the board and compare the result with your prediction.
Investigate: Work out why it happens, one step at a time.
Modify: Change the problem on purpose and see what happens.
Practise: A few on your own, to check you have it.
Make: Make your own problem using what you have learned. Expect a few tries; that is normal.
Make your prediction first. Help opens once you've locked it in.
PredictRead the problem and decide what you think before you try anything. A wrong guess is fine: it shows you what to look for.
A run of failures
TryTry it on the board and compare the result with your prediction.
Try: read the log as the admin
Was your prediction right?
Try it yourselfYour edits are saved in this browser.
You are on the target as admin. Find the failed logins: sudo grep Failed /var/log/auth.log.
Use the board. This ticks when you get there.
InvestigateWork out why it happens, one step at a time.
Worked example: Counting and comparing
Worked exampleBefore each step, say what you think comes next.
A computer records every login attempt. A long run of failures for one account from one address in a short time is someone guessing passwords. Reading the log is the defender's view of an attack, and the fix is to make guessing harder, not to hope it fails. About 40 minutes.
I can find failed and successful logins in auth.log.
I can say what a guessing pattern looks like.
I can name a defence that makes guessing pointless.
Before class
Try the boards yourselves.
The gate (read first). This course teaches security as audit and defence: you scan, read and fix a lab computer your class owns. The pretend Kali and target in the lessons are safe anywhere. The real-lab version is different, so it needs your sign-off before anyone starts: school policy and IT's agreement, a written lab agreement every student signs (lab-rules.txt on the board is a model), and a lab that is cut off from every other network: a Pi running Kali and a second Pi or a virtual machine as the target, joined by one switch or one ethernet cable, with no router and no internet. Download the Kali image and any tools once, at home or at IT's request. Scan only the target named on the lab sheet. This course does not teach breaking into anything: it stops at find, understand and fix. It relaxes the 'defensive only' rule of the other courses only in that the real lab uses real scanning tools on a computer the class owns.
Simplifications: the log on the board is made up for the lesson (14 failures from one address, one success). The pretend admin can read it with sudo; on a real Pi the first account can read it without. The addresses are private lab addresses. This lesson stays on the defender's side: it reads and counts, and does not teach how guessing is done.
Real lab, if you run one: Kali Linux has a Raspberry Pi image (Pi 4 or Pi 5; the Pi 5 wants its 27 W supply); flash it with Raspberry Pi Imager or the Kali image instructions and boot it with a screen and keyboard, or ssh in. The target can be a second Pi (an older Raspberry Pi OS with a few extra services) or a purpose-made practice target your IT team approves. Start from the same state every time: re-flash, or snapshot a virtual machine. nmap is already on Kali. Give each pair a printed lab sheet naming the target's address, the one account they may use and what they are allowed to change.
Other options: fail2ban blocks addresses automatically after repeated failures; journalctl -u ssh is the same story on systems that use the journal; a central log server keeps the record safe from the computer being attacked.
With internet: a server on the open internet is guessed at within minutes, all day, by automated scanners. That is why exposing a server raises the stakes (see System admin on a Raspberry Pi).
Running the lesson
Predict: wrong answers treat failure as success of the defence.
Try: ask which user the failures target.
Worked example: stop at Sam and ask what the 'Accepted' line means a week later.
Vary: ask what the single success might be.
Make: ask what number the report should lead with.
The hard part (on purpose)
Seeing the pattern rather than the lines. Ask what a real person who forgot a password looks like.
When students get stuck
Permission denied reading the log. Ask: Did you use sudo? Fix: sudo grep ... /var/log/auth.log.
fails.txt is empty or missing. Ask: Where is your > ? Fix: sudo grep -c ... > fails.txt
Stretch and support
Stretch: Find out what fail2ban does and what it cannot protect against.
Support: A card of the three grep commands.
Where it leads
Links: Security and privacy › Sign-in and permissions; Cyber safety and privacy › Passwords; next: Close the doors.
What each step is for
a run of failures: Committing to what a pattern in the log means tests the new move: patterns, not single lines, carry the story.
Try: read the log as the admin: Reading the log settles the prediction.
Worked example: Counting and comparing: Following the method once, then finding where a plausible account goes wrong, models the new move.
Vary: change one thing: Each task changes one thing: the count, the successful logins, and the account being targeted.
Practise: Reading patterns and choosing defences is the same move in new forms, plus a review of versions.
count and keep it: Turning a log into a number for the report is the whole move.