Linux server hardening: the checklist
20 measures that apply to every Linux server running websites – with the matching command for Debian and Ubuntu and a note on which of them tyrosec checks for you continuously.
Reviewed by Marcus Schmidt · as of November 2026
1. Updates and packages
- Install security updates automatically
apt install unattended-upgradesand enable it. tyrosec shows open vulnerabilities, sorted by exploitation. - Watch the end of supportReplace operating systems, PHP and applications without security updates. tyrosec warns before the end of support.
- Restart after updates
needrestartshows services still using old program versions. tyrosec reports them too. - Remove unneeded packages
apt autoremove --purge– less software, fewer vulnerabilities. Not checked by tyrosec.
2. SSH and login
- Log in with keys only
PasswordAuthentication noin/etc/ssh/sshd_config; keep a second session open first. tyrosec reports password logins. - No root login with a password
PermitRootLogin prohibit-passwordorno. tyrosec reports root logins. - Know your authorised keysReview all
authorized_keysregularly. tyrosec reports new keys and logins with unknown keys. - Slow down brute forcefail2ban or CrowdSec against password guessing. tyrosec detects attack waves and the successful login afterwards.
3. Network and services
- Firewall with “deny all” as the default
ufw default deny incoming, then open only the ports you need. tyrosec reports when the firewall is disabled or loosened. - Databases on localhost only
bind-address = 127.0.0.1for MySQL/MariaDB, Redis on localhost only. tyrosec finds them and checks from outside whether they are reachable. - Know your open ports
ss -tlnplists all services with ports. tyrosec reports new publicly reachable ports. - Disable unneeded services
systemctl disable --now <service>. tyrosec reports newly created services and timers.
4. Web and applications
- No sensitive files in the web folder
.env,.git, backups and database dumps do not belong in the web folder. tyrosec checks from outside whether they can be downloaded. - No PHP in upload foldersBlock PHP execution in upload folders in the web server. tyrosec reports every PHP file there immediately.
- Debug mode off
APP_DEBUG=false,WP_DEBUGwithout display. tyrosec checks this per application. - Configuration not writableConfiguration files not writable by the web server, e.g.
chmod 640. tyrosec reports writable configurations.
5. Monitoring and incidents
- Monitor file changesWatch system and web folders for unplanned changes. tyrosec in real time, with diff and restore.
- Review logins and logsSuccessful logins matter more than a thousand failed ones. tyrosec analyses SSH and web logins.
- Check backups – and test restoringA backup only counts once a restore has worked. tyrosec warns when backups stop.
- Define an incident planWho gets notified, who acts, who informs clients? Not checked by tyrosec – but the incident report provides timeline and evidence.
Why a checklist alone is not enough
A checklist describes one point in time. Servers change every day: updates, new plugins, a colleague opens a port “just for a moment”. One-off audit tools like Lynis show today’s state – not what happens tomorrow.
tyrosec checks the marked items continuously and reports as soon as one of them flips. Hardening guides such as the CIS Benchmarks or the German BSI module SYS.1.3 “Servers under Linux and Unix” cover the rest.
Frequently asked questions
How often should I check a Linux server?
Updates and logins daily, hardening after every major change and at least once a quarter. With tyrosec, file monitoring and logins run in real time and the compromise check daily.
Do the commands work on other distributions?
The measures do; the commands are for Debian and Ubuntu. On RHEL, Rocky or Alma the counterparts are e.g. dnf-automatic and firewalld.
Are there official hardening guides?
Yes, for example the CIS Benchmarks per distribution and the BSI module SYS.1.3 “Servers under Linux and Unix”. Both go deeper than this checklist – see sources.
See what’s happening on your server in two minutes.
Install the agent with a one-liner, wait for the initial scan, done. 14 days free, up to 3 servers, no credit card required.
Sources
- CIS Benchmarks: https://www.cisecurity.org/cis-benchmarks
- BSI IT-Grundschutz: SYS.1.3 Servers under Linux and Unix (PDF, German): https://www.bsi.bund.de/SharedDocs/Downloads/DE/BSI/Grundschutz/IT-GS-Kompendium_Einzel_PDFs_2023/07_SYS_IT_Systeme/SYS_1_3_Server_unter_Linux_und_Unix_Edition_2023.pdf
- Debian wiki: unattended upgrades: https://wiki.debian.org/UnattendedUpgrades
- Lynis (CISOfy): https://cisofy.com/lynis/
As of November 2026. Commands for Debian and Ubuntu; always keep a second session open before changing SSH or the firewall.