The Homelab Handbook

Practical guides for Linux servers, networking, and self-hosting.

Security

Security is not a product you install; it is a set of habits, most of them boring. The boring habits are the ones that work.

SSH hardening

SSH is the front door. Key-only authentication, no root login, and no password authentication:

# /etc/ssh/sshd_config
PasswordAuthentication no
PermitRootLogin prohibit-password
PubkeyAuthentication yes

Restart sshd after editing, and keep a second session open while you test — locking yourself out of your own server is a rite of passage best experienced once.

Fail2ban

Fail2ban watches logs and temporarily bans IPs that fail authentication too many times. It does not make you secure; it makes the noise quieter, which lets you notice the signal.

Updates

Most compromises exploit known vulnerabilities with patches already available. Automatic security updates are the highest-return security investment you can make. Schedule a reboot window for kernel updates and get on with your life.

Least privilege

Every service should run as its own user with only the permissions it needs, and every port that is open should be open for a reason you can state in one sentence. If you cannot state the reason, close the port and see what breaks — that tells you whether the reason was real.

Backups

Back up configuration and data off the machine, automatically, and test the restore. A backup that lives on the same disk as the data it protects is a copy, not a backup. The 3-2-1 rule is a good target: three copies, two different media, one off-site.