server_hardening
Tags: system, hardening, security
Secrets needed: No
Runs on: server and vps groups (site.yml gates on group membership)
Applies reliability and light security hardening for long-running server hosts.
What It Does
- journald: sets
SystemMaxUse=500Mand vacuums journals to that size - swap: creates a 2G
/swapfileif missing, sets 0600, runsmkswap+swapononly when it isn't already active, adds it to/etc/fstab - NTP: enables and starts
systemd-timesyncd - SSH rate limits:
MaxStartups 3:50:10,MaxSessions 10,ClientAliveCountMax 3insshd_config(reloads sshd) - UFW: turns logging on if UFW is already active (doesn't enable UFW or add rules)
- Livepatch: runs
pro enable livepatchif Ubuntu Pro is attached (best-effort) - Reboot check: prints a warning if
/var/run/reboot-requiredexists
Notes
- Does not install fail2ban, change SSH auth/cipher settings, set sysctls, or configure automatic updates
- No
skip_flag — to keep a host out, take it out ofserver/vps - The retired VPSes (
matrix,telengana) are still invps; don't apply to them (see the cutover runbook) — this role reloads sshd and restarts journald