Practise this module for free on a real VM
Sign up for freeHello World
Your start in the lab: in a few minutes you learn how the automatic check verifies your solutions on the real VM — and you finish by blocking root login via SSH. 4 short tasks.
Validator tour
Welcome — how the validator works
This short intro module shows you how the lab checks your solutions. Every task is automatically validated on your real VM — you get instant feedback whether it passed. You will meet three kinds of checks here:
- File content (file_content): checks whether a file contains a certain text.
- Command output (command_output): runs a command and checks its output.
- Service status (service_status): checks whether a system service is running.
This way you know exactly what "Check" means in all later modules. Click Check after each task.
Your goal
You solve one task per check type and finish with real mini hardening: you block root login via SSH.
Exercises
1. File content check
Check type 1: file content. This check verifies whether a file contains a certain text. Write
Lab Sessioninto the file/etc/issue(the login banner).echo "Lab Session" | sudo tee /etc/issueCheck:
/etc/issuecontains the textLab Session.2. Command output check
Check type 2: command output. This check runs a command and verifies its output. Enable the UFW firewall so that
ufw statusreturns the textStatus: active.sudo ufw --force enable sudo ufw statusCheck:
ufw statusoutputsStatus: active.3. Service status check
Check type 3: service status. This check verifies whether a system service is running. Start the
fail2banservice.sudo systemctl ____ --now fail2banCheck: the
fail2banservice isactive(systemctl is-active fail2ban).4. Mini hardening: block root login
Check type 2 once more — this time with real hardening. A server that lets
rootlog in via SSH is the favourite target of automated attacks. You block root login and make the SSH service load the change. The checker usessshd -Tto read the effective configuration: all files together (including/etc/ssh/sshd_config.d/) plus defaults — the way SSH applies it the next time it loads.In
/etc/ssh/sshd_config, set the optionPermitRootLogintono, then reload the SSH service.sudo sed -i -E 's/^#?PermitRootLogin.*/PermitRootLogin no/' /etc/ssh/sshd_config sudo systemctl reload sshWithout
reloadthe running service keeps using the old value until it restarts. The check does not notice (sshd -Treads the files) — so the reload always belongs to the job.Check:
sudo sshd -T | grep permitrootloginshowspermitrootlogin no.
Knowledge check: Hello World
No VM needed, about 3 minutes. You recall what you practiced in this module – wrong answers come back at the end.
Related courses
Now practice it yourself
Reading is good – doing is better. Practise this module on a real Linux VM, right in your browser. A free account is all it takes.
Start for freeLab content under CC BY 4.0 – free to use with attribution (© TechLogia).
