U6 Security and Services

Securing your homelab in layers

Perfect security does not exist. Layers do. Each one you add makes your lab a little less attractive than the next easy target, and makes a single mistake survivable. This guide covers the layers that matter most, in roughly the order to build them.

At a glance

  • Most attacks are automated and opportunistic. Do not be the easiest target on the internet.
  • Expose nothing by default. Reach your lab through a VPN or overlay.
  • Patch automatically. Disclosed vulnerabilities are exploited within hours, and old ones are exploited for years.
  • Use a password manager, long passphrases and hardware security keys, and buy two keys.
  • Assume something will be compromised eventually, and design so it cannot reach everything else.

A realistic threat model

For most homelabs, the threat is not a skilled attacker who wants your data specifically. It is automated scanning that probes every public address on the internet, looking for exposed admin pages, default passwords, unpatched applications and open file shares. When it finds one, it installs crypto miners, joins your devices to botnets or encrypts your files for ransom.

Two exceptions are worth considering. If your job gives you access to valuable systems, your home network could become a stepping stone into your employer's, so treat your lab with more care. And even if nobody else values your data, you do. Family photos are irreplaceable to exactly one household.

Rule of thumb

Convenience is the enemy of security, but security that is too inconvenient gets bypassed. Choose the secure options that are also easy to live with: key-based logins, automatic updates, a VPN profile on your phone, a password manager with autofill.

Layer 1: minimal exposure

  • Close every inbound port that you cannot justify. Disable automatic port opening (UPnP) on your firewall.
  • Never expose management interfaces, file shares, databases, camera recorders or remote desktop to the internet. Our field note Keep Management Off the Internet explains why this matters so much.
  • Use a VPN or mesh overlay for your own access. See Remote Access and VPNs.
  • Host truly public services away from home when you can, on a rented server isolated from your network.
  • Verify from outside. Scan your public address from another network and confirm nothing unexpected answers.

Layer 2: patching

The time between a vulnerability being published and attackers exploiting it in bulk has shrunk to hours for internet-facing devices, and attackers increasingly use automated tools to turn published fixes into working exploits. Meanwhile, flaws that are years old remain among the most exploited, because so many devices never get updated.

  • Enable automatic security updates on every Linux server.
  • Update the firewall, switches, access points and NAS on a schedule, and immediately when a serious advisory affects them.
  • Keep browsers current. The browser is one of the largest attack surfaces you have.
  • Replace devices that no longer receive updates, especially anything that faces the internet.
  • Patch internal systems too. Real attacks chain a remote flaw with a "local only" privilege escalation.

Layer 3: strong authentication

Password manager

Use one, with a long passphrase made of several random words as the master password. Never reuse passwords. A browser-integrated manager that matches exact addresses is also a phishing defense: if autofill does not offer your password, stop and look closely at the address. Prefer managers that are open source and independently audited, and keep an encrypted export as part of your backups.

Multi-factor authentication

  • Hardware security keys are the strongest common option and are convenient: touch the key and you are in. Buy two, register both everywhere you can and store the spare somewhere safe away from home.
  • Time-based codes from an authenticator app are a good second choice. Keep codes for critical accounts in a separate app from your password manager, so a single stolen vault does not hold both factors.
  • Avoid text message codes where better options exist, and be wary of services that let an email link reset your second factor, which undoes its purpose.
  • Print recovery codes and store them with your important documents.

SSH

Keys with passphrases, password and root logins disabled, logins limited to named accounts, and automatic banning of repeat failures. Details in Linux for the Homelab.

Layer 4: segmentation and least privilege

Assume one device will eventually be compromised. Segmentation decides what it can reach next.

  • Put IoT devices, cameras, guests and the lab on separate networks, with firewall rules that allow only necessary traffic. See VLANs and Segmentation.
  • Write rules between servers too. A media server and a web server have no reason to talk. An application server may reach its database; nothing else should.
  • Have internal admin interfaces answer only the reverse proxy or a jump host, so a network scan from elsewhere finds nothing.
  • Keep authentication on internal services. "It is only reachable from inside" is not a password.
  • Run services as unprivileged users, and give automation accounts only the permissions they need.

Layer 5: supply chain

Most software in a homelab was written by strangers. That is fine, as long as you choose the strangers carefully.

  • Prefer distribution repositories and software published by the project itself.
  • Use official container images, or build your own. Be wary of images and packages from unknown individuals.
  • Read scripts before piping them into a shell, and do not run helper scripts that you do not understand on hosts that matter.
  • Treat abandoned projects as a risk. No published vulnerabilities often means nobody is looking.
  • Remove software you no longer use.

Layer 6: detection

You cannot detect everything, but you can detect the things that should never happen at home.

  • Alert on every SSH or admin login. In a lab with one administrator, every alert you did not cause is worth investigating.
  • Send logs off each host to a central log server, so an intruder who clears local logs leaves evidence elsewhere.
  • Place tripwires: a decoy credential or file that nothing legitimate touches, which alerts if used.
  • Watch for unexpected outbound connections, new processes and sustained CPU use on hosts that are normally idle.

See Monitoring and Logging for building this without drowning in alerts.

Layer 7: recovery

Security is not only prevention. When something does go wrong, your backups and documentation decide whether it is an evening's work or a disaster.

  • Keep backups that the compromised system cannot delete, with separate credentials. See Backup Strategy.
  • Separate operating systems from data, so you can rebuild a server cleanly rather than trying to clean an infected one.
  • Rotate every credential after an intrusion, before restoring.
  • Write a short incident runbook now: what to unplug, what to rotate, what to restore and in what order.

Audit regularly

Configuration drifts and temporary exceptions become permanent. Schedule an audit every quarter:

  1. Scan your public address from outside and compare with what you expect.
  2. List listening services on each server with ss -tlnp and remove what has no purpose.
  3. Review firewall rules and delete temporary ones.
  4. Run a host security audit tool on your Linux servers. Expect dozens of suggestions; fix the serious ones first and ignore the cosmetic.
  5. Check for devices without updates and plan their replacement.
  6. Test a restore and confirm recovery keys are where your documentation says they are.

Our printable quarterly audit checklist covers all of this.

Security keeps intruders out. Privacy decides who sees your data in the first place. The biggest privacy gain in a homelab is data ownership: keeping photos, notes, documents and home automation on hardware you control, backed up and encrypted, rather than in services that can be breached, sold or changed. Do not spend weeks comparing DNS providers; spend that time moving your important data home. See Self-Hosting Services.