RU
🤖 AI Engineering

Nothing Public, No Passwords: Securing a Family Server Run by AI Agents

A rented VM holds my family's bank statements, savings and health pages, and Claude agents work inside it. Five layers keep it closed: an encrypted disk, no public ports, identity from Tailscale instead of logins, one Unix user per person, and agents that never type a password. Plus what it doesn't protect against.

One rented VM holds my bank statements, our budget, savings and health pages, and a Claude agent for each of us lives on it. Mine reads my mail. A well-worded email or screenshot can talk any of them into something.

Once the disk is unlocked, nothing on the server answers from the internet: an external scan finds the common ports closed and no public IPv6. My partner and I open the same https://home.<tailnet>.ts.net and each of us sees only our own data, with no login page and no passwords. The agents can’t type a password at all. When a site needs a login, my phone gets a push and I log in myself.

Two things it doesn’t protect against: the provider can read a running machine, and root sees everything (I’m root).

When I moved this off my Mac, I asked Claude for “classic cryptography” and “an agent that checks security once a day, because I’m not going to sysadmin it myself.” It agreed, with a correction I keep coming back to: the server is safe because it’s closed, and an agent watching it adds nothing to that. unattended-upgrades installs the updates. The agent only reports.

What I protect against, and what I accept

Cutaway of a small house-shaped server: a locked front door, then a separate room and key for each person; an orange AI assistant with a notepad holds up a glove away from the keypad while a human hand types the code

I wrote the threat model down before the configs, in plain words.

Protected:

  • the internet: scanners, brute force, the next exploit in something I forgot was listening;
  • the provider’s storage: snapshots, backups, a disk that gets decommissioned and resold;
  • one family member reading another’s data, or their agent doing it;
  • prompt injection: an email or screenshot that talks an agent into doing something;
  • losing the data: my mistake, a bad update, the provider losing the VM.

Accepted:

  • the provider can read a running machine. The disk key sits in RAM and the hypervisor owns the console. Encryption doesn’t change that.
  • /boot and the initramfs aren’t encrypted, dropbear’s host key included. Someone who can write to the disk can tamper with the unlock step; that’s part of trusting the provider.
  • root sees everything. I’m root. My partner trusts me with the server the way she’d trust me with the router.

1 · Encrypted disk

provider snapshots, disposed disks, backups read at rest

2 · Nothing public

internet scans: default-deny firewall, tailnet only, services on localhost

3 · Identity from the tailnet

strangers and tagged devices: routing by Tailscale login, else 403

4 · People are Unix users

one family member reaching another's files or local ports

5 · Agent rules

prompt injection: no passwords, explicit yes, a read-only observer

Family data: plain files under git

Around it all · backups

restic to another datacenter, weekly test restore, provider snapshots

Each ring assumes the one outside it has already failed.

Layer 1: an encrypted disk on someone else’s computer

The VM runs Ubuntu 26.04 on LUKS → LVM → ext4. There’s a passphrase at boot and no keyfile anywhere. I chose the provider partly for one feature: its web console can mount an ISO, so I could install with full-disk encryption myself instead of asking support.

A passphrase at boot on a machine with no keyboard needs another way in. dropbear runs in the initramfs, only while the disk is locked:

/etc/dropbear/initramfs/dropbear.conf
# key-only (-s), no port forwarding (-j -k), 5-minute idle timeout, and the only command is unlock
DROPBEAR_OPTIONS="-p <port> -s -j -k -I 300 -c cryptroot-unlock"

It has its own host keys, so the Mac keeps a separate known_hosts for it, and its own SSH key. ufw doesn’t run that early, so for the minutes the server waits at boot the unlock port is open to the internet. dropbear there takes one key and can only run the unlock command. If your provider has a cloud firewall, that’s where to narrow it. If dropbear doesn’t come up, the fallback is the provider’s web console.

I turned automatic reboot off. After a kernel update an unattended reboot would leave the server waiting at the passphrase prompt until I noticed. Instead the morning report says “reboot needed” and I reboot when I can unlock it.

Layer 2: nothing public

The firewall is four lines:

provision.sh (firewall, core)
ufw default deny incoming
ufw default allow outgoing
ufw allow in on tailscale0
ufw --force delete allow 22/tcp # public SSH closed once the tailnet works

Every service binds 127.0.0.1: the site, Caddy, the browser screen, the task tracker’s Docker ports. Public sshd still listens, but the firewall drops it. I administer the box over SSH on the tailnet. Tailscale Serve terminates HTTPS on the tailnet name and forwards to Caddy on localhost, and a second HTTPS port goes to the self-hosted tracker. Funnel, which would publish a Serve endpoint to the internet, is off.

Then I checked from outside. The scan matched the plan: common ports closed, no public IPv6.

I put one guard into provision.sh so I can’t lock myself out of a remote box: if the script runs over a session that didn’t come in through Tailscale, it refuses to enable the firewall unless I force it.

Layer 3: identity without passwords

The site has no login page and no passwords. Tailscale already knows who’s connecting: when Serve proxies a request from a user’s device, tailscaled adds a Tailscale-User-Login header. Caddy routes on it:

Caddyfile (sanitized)
http://:<caddy-port> {
bind 127.0.0.1
@me header Tailscale-User-Login {$ME_LOGIN}
handle @me {
handle_path /browser/* {
reverse_proxy 127.0.0.1:<my-vnc-web-port>
}
reverse_proxy 127.0.0.1:<my-site-port>
}
@partner header Tailscale-User-Login {$PARTNER_LOGIN}
handle @partner { ... }
handle {
respond "Forbidden" 403
}
}

Unknown login → 403. Tagged devices don’t get the header at all, so they get 403 too. This only works because Caddy is unreachable except through tailscaled. If anything else on the box could reach Caddy directly, it could set the header itself. Layer 4 exists partly for that.

The tailnet ACL does the rest: my devices reach everything, my partner’s reach only HTTPS. She has no SSH, no tracker port, nothing else.

Layer 4: people are Unix users

My partner is a separate Unix user, not a folder in my home. Each person gets their own home (0750), their own ~/Vault git repo (0700), their own secrets file (0600), and their own Claude login. She signed in to her own account; the agent can’t do that for her. There’s one shared group directory for family things.

Every per-person service is a systemd template unit, home-web@<user>, home-rc@<user>, home-browser@<user> and so on, with User=%i and a hardening block (the browser unit runs a shorter one). This is the real one from the site unit:

home-web@.service (hardening)
UMask=0077
NoNewPrivileges=yes
ProtectSystem=strict
ProtectHome=tmpfs
BindPaths=/home/%i
ReadWritePaths=/home/%i -/srv/family
PrivateTmp=yes
PrivateDevices=yes
ProtectKernelTunables=yes
ProtectKernelModules=yes
ProtectKernelLogs=yes
ProtectControlGroups=yes
ProtectClock=yes
ProtectHostname=yes
RestrictSUIDSGID=yes
RestrictRealtime=yes
LockPersonality=yes
RestrictAddressFamilies=AF_UNIX AF_INET AF_INET6 AF_NETLINK

ProtectHome=tmpfs plus BindPaths means the other person’s home doesn’t exist inside the unit, so a permissions mistake there can’t leak it. I’d like the whole home to be read-only, but Claude, its MCP servers and the tools write all over $HOME, so the user’s own home stays writable.

Files were the easy part. Ports are easier to miss. Everything listens on 127.0.0.1, and loopback is shared by every user. Her agent could curl my site’s port, or my browser’s DevTools port, and drive my logged-in Chromium. So the firewall also filters loopback by owner:

/etc/ufw/before.rules (sanitized)
# my site: only Caddy and me
-A ufw-before-output -o lo -p tcp --dport <my-site-port> -m owner ! --uid-owner caddy -m owner ! --uid-owner <me> -j REJECT
# my browser's CDP and VNC: only me
-A ufw-before-output -o lo -p tcp --dport <my-cdp-port> -m owner ! --uid-owner <me> -j REJECT
-A ufw-before-output -o lo -p tcp --dport <my-vnc-port> -m owner ! --uid-owner <me> -j REJECT
# the browser screen over websockify: Caddy and me
-A ufw-before-output -o lo -p tcp --dport <my-vnc-web-port> -m owner ! --uid-owner caddy -m owner ! --uid-owner <me> -j REJECT
# Caddy itself: only root (tailscaled)
-A ufw-before-output -o lo -p tcp --dport <caddy-port> -m owner ! --uid-owner root -j REJECT
# Caddy's admin API: root and caddy only
-A ufw-before-output -o lo -p tcp --dport <caddy-admin-port> -m owner ! --uid-owner root -m owner ! --uid-owner caddy -j REJECT
# ...and the mirror image for my partner

The rules sit above ufw’s default loopback ACCEPT, otherwise they never match. The Caddy rule is the one that keeps layer 3 honest. Only tailscaled can talk to Caddy, so only tailscaled sets the identity header. Caddy’s admin API needs the same treatment: without that rule any local user could rewrite the routing.

Layer 5: the agents

The agents are the part that’s new, so this is where I was strictest.

The agent never types a password. Each person has a persistent Chromium on the server that the agent drives over CDP. When a site needs a login, the agent runs need-login.sh, which sends a push to the phone with a link to that browser’s screen. I tap it, log in myself (password, 2FA app, code), press “Done”, and the agent continues. The screen is served through Caddy only to its owner.

Send, pay, confirm, delete only after an explicit yes to the specific text or action. That’s in each person’s ~/.claude/CLAUDE.md, and the auto-mode settings say the same about sending mail and deleting tasks or events. In interactive sessions the pre-approved mail tools stop at drafts. A model rule like this can fail, so the layers underneath are written as if it will.

The admin agent can’t see the data. ops is in none of our groups, so the 0750 homes and the family directory are closed to it, and its sudo is a fixed read-only list. Arguments in sudoers match exactly, so one extra flag means a refusal. One thing it does read is a day of system-journal warnings, so our services shouldn’t log data there.

/etc/sudoers.d/ops-readonly (core)
Cmnd_Alias OPS_RO = /usr/bin/apt list --upgradable, \
/usr/bin/systemctl status --no-pager, \
/usr/bin/systemctl --failed --no-pager, \
/usr/bin/journalctl --no-pager -p warning -S -24h -o short-iso, \
/usr/sbin/ufw status verbose, \
/usr/bin/df -h, \
<restic wrapper> snapshots, \
<restic wrapper> check
ops ALL=(root) NOPASSWD: OPS_RO

The morning check doesn’t depend on a model. Every morning alerts.sh checks, with no model involved: reboot required, security updates that didn’t install, failed units, backup freshness and the weekly restore result, disk over 85%, a new tracker release, and known vulnerabilities in the site’s Python dependencies (OSV). Each problem becomes a ! … line, and any such line means a push to my phone. Then Claude gets the collected output on stdin and writes the readable report:

ops/report.sh (core)
claude -p "$(cat prompt.md)" --tools "" --strict-mcp-config --no-session-persistence --max-turns 1 < "$RAW"

--tools "" and --strict-mcp-config mean it can’t run anything. If a log line tries to inject instructions, the worst case is a strange paragraph in a report I read. The push headline comes from the script, so a bad answer can’t turn a problem into “all good”. The report goes to an outbox that only ops can write and, apart from ops, only I can read.

Backups and the data format

The little house-shaped server on one hill and, far away on another, a tiny copy of it inside an open safe, next to a checklist with the first item ticked

restic runs nightly to a storage box in another datacenter over SFTP. It keeps 7 daily, 4 weekly and 6 monthly snapshots, and the provider’s own snapshots sit on top. Once a week a job runs restic check with a sample of the data, restores one random file that hasn’t changed since the snapshot, and compares its sha256 with the live copy.

The data is plain files: CSV, Markdown, JSON, each person’s in a git repo with auto-commits. No database. I can read them without the app, diff any change an agent made, and roll it back. When I moved from the Mac, I compared every file’s sha256, and the budget report the server generated matched the Mac’s character for character.

Where it bit

The first encrypted boot didn’t accept my passphrase. Probably an extra character during install. I ended up in an emergency shell and opened the disk by hand with cryptsetup open and vgchange -ay. Then a power cycle interrupted the install, and I had to create the user through GRUB with init=/bin/bash.

The provider’s web console mangles Shift characters. Over the browser-based VNC, typed uppercase and symbols come out wrong. Check that your recovery path can type your actual passphrase before the day you need it.

The site served a secrets file. The file browser hid a secrets note by exact filename, case-sensitively, so a differently cased copy went through. Nobody outside the tailnet could reach it, but layer 4 is supposed to assume layer 3 failed. The fix was a whitelist of extensions instead of a blacklist of names, plus Host and Origin checks against DNS rebinding and CSRF, both covered by self-tests.

Chromium wanted --no-sandbox. Ubuntu 23.10+ blocks unprivileged user namespaces, and Chromium’s sandbox needs them. Every guide says to pass --no-sandbox. That’s the wrong trade for a browser an agent points at arbitrary sites. A small AppArmor profile allows user namespaces for that one binary, and the sandbox stays on.

Claude refused to widen its own permissions. On the server I asked Claude to edit its own permission settings, and later to add my partner’s rule to the tailnet ACL. Claude Code’s safety classifier blocked both as self-modification. I applied them myself. Annoying, and it’s what I want: an agent that can grant itself access makes the other layers optional.

What’s still open

  • The boot-time unlock path is configured, but I haven’t tested every failure case end to end. The console is the fallback I know works.
  • There’s no outside uptime check yet. If the whole VM goes down, the morning report doesn’t arrive and nothing tells me.
  • The agents read untrusted mail and can run commands as their user. The Unix user, the unit sandbox and the owner rules limit the damage. They don’t remove the risk.

Build your own: paste this into Claude Code

Disk encryption has to happen at install time, so install the VM with LUKS first (or accept that the disk isn’t encrypted). Then run Claude Code on your own machine with SSH access to the VM, and paste:

prompt.md
Help me harden a fresh Ubuntu VM that will hold personal data and run AI agents.
Go step by step, show every command before running it, and ask before anything that could cut off my access.
Never type passwords or passphrases for me; I'll type them.
1. Threat model: write down with me what we protect against and what we accept (provider access to a running VM, root).
2. Network: SSH by key only, no passwords. Use a dedicated SSH key for this server, protected by a passphrase or a hardware key.
Install Tailscale, then ufw with default deny incoming and one rule `allow in on tailscale0`.
Only after I confirm SSH over the tailnet works, remove public SSH. Leave Funnel off.
Replace the default allow-all tailnet ACL with explicit per-user rules. Turn on 2FA for the Tailscale identity provider
and the VPS provider account: the provider console can reboot the VM and rewrite the unencrypted /boot.
3. Services: every service binds 127.0.0.1. If a service runs in Docker, publish ports as 127.0.0.1:PORT:PORT:
Docker-published ports bypass ufw. HTTPS through `tailscale serve` to a reverse proxy on localhost.
Route by the Tailscale-User-Login header, 403 for anything unknown. No passwords on the site.
Trust the Tailscale-User-Login header only because the proxy is reachable solely via tailscaled.
Never expose the same proxy any other way.
4. Users: one Unix user per person, homes 0750, secrets 0600. Per-user systemd template units with User=%i,
ProtectSystem=strict, ProtectHome=tmpfs + BindPaths for their own home, PrivateTmp, NoNewPrivileges.
5. Loopback: ufw-before-output owner rules in /etc/ufw/before.rules, above the default loopback ACCEPT,
so each local port is reachable only by its owner (and the proxy), and the proxy only by root/tailscaled.
Also lock down the proxy's admin API (for Caddy: `admin off`, or an owner rule on its admin port),
otherwise any local user can rewrite the routing.
6. Agents that read untrusted input (mail, screenshots): list allowed tools explicitly (no blanket MCP server or Bash)
and consider restricting their outbound network.
7. Updates: unattended-upgrades on, automatic reboot off if the disk is encrypted.
8. Backups: restic to a different provider or location, nightly, plus a weekly check that restores
one file and compares its hash. Tell me where to store the restic password.
9. Monitoring: a deterministic shell script for reboot-required, pending security updates, failed units,
backup age, disk usage. If a model writes a summary, run it with no tools and no MCP.
10. Finish with a port scan of the VM's public IP from my machine (not from the VM) and show me the result.

Next: what our Home looks like from the inside, now that it’s locked down.