Skip to content

Appendix F — New VPS Hardening Checklist (Printable)

This is the checklist version of the book. Work it top to bottom the first time you build a server, then keep it as a yearly audit. Each line is one decision or one check. The link after it points to the chapter that explains why. If a line puzzles you, that is the chapter to read.

  • Pick a region close to your users, and write down why. Chapter 4
  • Decide size with some slack, then set a billing alert before you create anything. Chapter 4
  • Decide now: throwaway lab or production. If it is production, every line below is required. Chapter 4
  • Give the server a name that says what it is for, such as prod-web-1, not server. Chapter 5
  • Generate an SSH key on your laptop and paste the public key in at creation time. Do not plan to set a password later. Chapter 6
  • Put a cloud firewall in front of the server and set it to deny by default. Chapter 14
  • Apply all package updates. Chapter 5
  • Create a non-root user with sudo, and log in as that user from now on. Chapter 5
  • Confirm key-based login works for the new user. Chapter 6
  • Turn off password logins, and turn off root login over SSH. Chapter 6
  • Open a second SSH session and test the change there before you close the first. Keep the first session open until the second one works. Chapter 6
  • Turn on unattended security upgrades. Chapter 5
  • Set the timezone, and check that the clock syncs over NTP. Logs and certificates both depend on the clock being right. Chapter 5
  • Set the hostname to match the name in your notes. Chapter 5
  • Add a small swap file on low-RAM plans, so a memory spike does not end with the OOM killer picking a victim. Chapter 5
  • Cloud firewall allows 80 and 443 only, or nothing at all if you front the site with a Cloudflare Tunnel. Chapter 14
  • Host firewall defaults to deny, and only the ports you named are open. Chapter 14
  • SSH reaches the box over your private network (Tailscale or WireGuard), and public port 22 is closed. Keep a console login from your provider as the way back in. Chapter 16
  • Databases listen on 127.0.0.1 or an internal Docker network only, never on the public address. Chapter 7
  • Docker publishes ports with the bind address set, for example -p 127.0.0.1:3000:3000. Docker writes its own firewall rules, so an open-looking port may be open to the world. Chapter 7
  • Scan the server yourself from outside, and check that only the ports you expect answer. Chapter 15
  • A reverse proxy (Caddy or nginx) owns ports 80 and 443 and sends traffic to the app. Chapter 8
  • HTTPS certificates renew automatically, and you have seen one renewal succeed in the logs. Chapter 9
  • HSTS is on, but only after HTTPS works on every name you serve. HSTS is hard to undo once browsers remember it. Chapter 9
  • If Cloudflare sits in front, set SSL mode to Full (strict). Chapter 17
  • The origin accepts traffic only from Cloudflare, or only from the Tunnel, so nobody can bypass the doorman. Chapter 17
  • Admin, staging, and status pages sit behind an access gate, such as Cloudflare Access, or a VPN. Chapter 17
  • Registrar account has two-factor login, a registrar lock on the domain, and auto-renew on. Chapter 11
  • The DNS host account has two-factor login too. Whoever controls DNS controls everything. Chapter 10
  • A CAA record names the one certificate authority you actually use, so strangers cannot quietly get certificates for your names. Chapter 9
  • No dangling CNAMEs. Every name that points at a third-party service still points at something you own. Chapter 12
  • Mail has SPF, DKIM, and DMARC records, and the DMARC policy is at least none with a reporting address. Chapter 13
  • Before a migration, lower the TTL a day or two ahead, so the switch-over is quick to take effect. Chapter 10
  • The app runs as a non-root user, under systemd or with a Docker restart policy, so it comes back after a reboot. Chapter 7
  • The .env file is mode 600, owned by the app user, and sits outside any folder the web server serves. Chapter 7
  • Secrets are not in git. If one got committed, rotate it. Deleting the commit is not enough, because clones already have it. Chapter 7
  • Logs rotate, and disk usage is watched, so a chatty app cannot fill the disk at 3 a.m. Chapter 19
  • Backups follow 3-2-1: three copies, on two kinds of storage, with one copy off-site. Chapter 19
  • You have done a restore drill on a different machine and timed it. A backup you have never restored is a hope, not a backup. Chapter 19
  • Your recovery point (how much data you can lose) and recovery time (how long you can be down) are written down. Chapter 19
  • An uptime check runs from outside your network, and it alerts a phone, not an inbox nobody reads. Chapter 19
  • The backup job pings a heartbeat service when it succeeds, and that service alerts you when the ping stops. Chapter 19
  • Certificate expiry and domain expiry alerts are on. Chapter 9 and Chapter 11
  • A billing alert exists, and you know who receives it. Chapter 4
  • Your patch cadence is written down: when you check for updates, who reads the reports, and how fast critical fixes ship. Chapter 19
  • An offboarding list exists: who holds SSH keys, registrar logins, DNS logins, and cloud console access. Remove people and rotate shared secrets when they leave. Chapter 19

Scanners will find a new server within days of it getting an address. That is weather, not a personal insult. A failed line here is not a disaster. It is a to-do with a date on it.

Keep the printed copy with the server’s notes, and tick it again after every big change. For the commands behind these lines, see Appendix D, SSH, and for the messages you will meet along the way, Appendix E, Errors. Unfamiliar words are in Appendix G, Glossary.

Book 2 of a series. Book 1: The Glue.