Server Hardening in 3 Hours: Ubuntu and Windows Server
A practical, illustrated 3-hour guide to securing Ubuntu Server and Windows Server: accounts and SSH, firewalls, patching, sandboxing, auditing, LAPS, RDP, Defender, Credential Guard, logging and verification, with copy-ready commands.
- 12 lessons
- 3 h reading
- Free · no sign-up
What you'll be able to do
- Harden SSH, sudo and accounts on Ubuntu Server and validate the live settings
- Build a default-deny firewall and prove it from outside
- Automate patching and sandbox services with systemd
- Remove legacy protocols and apply a security baseline on Windows Server
- Deploy LAPS, admin tiering, gMSAs and a locked-down RDP setup
- Roll out Defender, ASR, Credential Guard and WDAC safely, in audit mode first
- Turn on the audit, PowerShell and Sysmon logging that catches real attacks
- Verify, score and maintain hardening with benchmarks, automation and a runbook
Server Hardening in 3 Hours is a hands-on guide to making a default server much harder to attack. It covers Ubuntu Server (24.04 and 26.04 LTS) and Windows Server (2022 and 2025), in the order you would actually do the work, with commands you can copy, a way to verify each change, and a way to back it out.
Twelve lessons add up to about three hours:
- Prepare: a threat model in five questions, a baseline inventory, and the safety rules that stop you locking yourself out.
- Ubuntu: named admins and key-only SSH, a default-deny firewall, automatic patching, systemd sandboxing, AppArmor, auditd, central logging, fail2ban and a Lynis score.
- Windows: removing legacy protocols (SMBv1, LLMNR, NetBIOS), Windows LAPS and admin tiering, locked-down RDP, Defender and Attack Surface Reduction, Credential Guard, WDAC, audit policy, PowerShell logging and Sysmon.
- Both: secrets, TLS, disk encryption, backups that survive ransomware, time sync, configuration drift, and a verification checklist with a final hardening report.
Every lesson has diagrams, command tables and a lab you can do in your own VMs, then a short checkpoint. Everything is for systems you own or are authorised to administer. Practise on VMs, take snapshots, and keep console access, because hardening is the one kind of work where a typo can lock you out.
Syllabus
- 1
Plan the three hours: threat model, baseline and rollback
Why hardening works, the order we follow, the safety rules that stop you locking yourself out, and the baseline inventory you capture on Ubuntu and Windows before changing anything.
- 2
Ubuntu: accounts, sudo and a hardened SSH daemon
Create named admin users, move to key-only SSH, lock root login, set a safe sudo policy, and audit accounts. Includes the first-match-wins trap in sshd drop-in files and how to validate before you reload.
- 3
Ubuntu: a default-deny firewall and a hardened network stack
Build a default-deny firewall with ufw (and a minimal nftables ruleset), scope SSH to your admin range, harden kernel network settings with sysctl, remove unused listeners, and prove the result with a scan from outside.
- 4
Ubuntu: automatic patching and sandboxing your services
Turn on unattended security updates with controlled reboots, learn Livepatch and ESM options, trim the package footprint, and use systemd's sandboxing options to confine services, scored with systemd-analyze security.
- 5
Ubuntu: file system, kernel settings, AppArmor and auditd
Find risky permissions and SUID files, apply safe mount options and kernel hardening, keep AppArmor enforcing, and install auditd rules that record changes to identity, sudo and SSH configuration.
- 6
Ubuntu: central logging, fail2ban and a Lynis audit
Make logs persistent and ship them off the host, add fail2ban for noisy sources, check file integrity with AIDE, and score your hardening with Lynis and Ubuntu Security Guide. Ends with the events worth alerting on.
- 7
Windows Server: a clean baseline, no legacy protocols
Choose Server Core, patch properly, remove unneeded roles, and turn off the legacy protocols attackers abuse: SMBv1, LLMNR, NetBIOS, NTLMv1, PowerShell v2 and the Print Spooler where it is not needed. Apply a Microsoft security baseline.
- 8
Windows Server: accounts, LAPS, admin tiering and RDP
Give every server a unique local admin password with Windows LAPS, separate admin and daily accounts, use Protected Users and gMSAs, and lock RDP down: NLA, scoped firewall, gateway or VPN, session limits and the right audit events.
- 9
Windows Server: firewall, Defender, ASR, Credential Guard and WDAC
Turn the host firewall into a default-block control, harden Microsoft Defender, deploy Attack Surface Reduction rules in audit then block mode, protect credentials with LSA protection and Credential Guard, and begin application control with WDAC.
- 10
Windows Server: audit policy, PowerShell logging, Sysmon and forwarding
Turn on the Advanced Audit Policy subcategories that matter, capture command lines, enable PowerShell script-block logging, add Sysmon for process, network and registry telemetry, size the logs, and forward them off the server.
- 11
Both platforms: secrets, TLS, disk encryption, backups, time and drift control
The controls that apply to every server: keep secrets out of files, automate TLS, encrypt disks, design backups that survive ransomware and test restores, keep time in sync, and use configuration management so your hardening does not drift.
- 12
Verify, measure and maintain: prove the hardening works
Test your servers from outside and inside, score them with benchmarks and Lynis, run the 3-hour acceptance checklist for both platforms, and keep it hardened with a patch cadence, exception log and a simple incident-readiness runbook.