Case file

Building a lab update agent where no AI holds the keys

4 min read

How I set up weekly patch reports for six hosts using AI, with a design rule that no AI ever gets a shell.

I run six hosts in my home lab: a hypervisor, a NAS, a reverse proxy, a Docker host, a DNS server and an app server. Keeping them patched by hand means logging into each one, reading package lists and guessing what is safe to apply. I wanted AI to do the reading and the thinking. I did not want it anywhere near a root shell.

  • Homelab
  • Security
  • Automation
  • AI
Six hosts report to Claude, which holds no SSH key Left: six hosts each print a read-only report through a forced command. Right: Claude reads those reports with read-only file tools, writes a patch proposal, and holds no SSH key. Six hosts forced command read-only report Claude read-only files patch proposal no SSH key

The rule

The whole design comes from one rule: no AI holds an SSH key.

If an AI can log in, a prompt injection can log in. Any text the AI reads, such as a log line, a package description or a hostname, could contain instructions aimed at it. So the AI only ever reads files. Everything that touches a host is a plain script that I can read in one sitting.

How it works today

Collecting. A dedicated VM runs a small script as its own user. It connects to each host over SSH with a key that is locked to a single forced command. That command prints a read-only report: uptime, disk, memory, pending updates, failed services, recent errors and listening ports. The key cannot open a shell, forward a port or run anything else, and each host only accepts it from the agent VM.

Analysing. Once a week, a Claude instance reads those reports. It has read-only file tools and nothing else. It cannot run commands or reach the network. Its job is to write a patch proposal: what is out of date, what needs a reboot, how risky each change is and how to roll it back. Nothing in the proposal is applied.

Reporting. A Discord bot posts the weekly report to a private channel. The scan job and the bot never talk to each other directly. The scan job drops a finished report into an outbox folder, and the bot picks it up. That way the scan job never sees the Discord token, and the bot never sees the reports until they are done.

Asking. The bot has two commands. /ask answers questions about the lab using the latest reports, so I can ask what is pending on a host without logging in. /chat is a general assistant with no tools and no lab access at all. I split them on purpose. The one that can read lab data cannot be a general-purpose chatbot, and the general one cannot read anything.

What went wrong along the way

  • A system group on one host already had the name I wanted for the scanner user. My setup script printed "ready" while the user creation had actually failed.
  • A leftover umask from an earlier session made the bot's files unreadable to the service account.
  • Systemd hardening options I wanted conflict with each other. NoNewPrivileges blocks the sudo call the bot depends on, and a read-only home directory stops Claude from refreshing its own login token.
  • Debian 13 does not create the timestamp file I was using to show when the package lists were last refreshed. I added an apt hook to write it myself.
  • The Antigravity CLI crashed with an illegal instruction on my VM, because the emulated CPU type hid a feature the binary needs. Switching the VM to the host CPU type fixed it.

None of these were hard. They were the sort of thing you only find by running it.

What is not built yet

These are planned, not working:

  • A second AI from a different vendor that reviews the first one's proposal and the raw reports.
  • A gate that checks every package in a plan against that host's real list of upgradable packages and rejects wildcards, pipes and command chaining.
  • Approve and Deny buttons in Discord, tied to a hash of the exact plan with an expiry.
  • A plain deterministic executor with its own user, snapshots before changes, health checks after, and rollback. It would apply only a plan I approved, one command at a time, and stop at the first failure.

Why two AIs are not the safety net

It is tempting to think two models agreeing means a plan is safe. It does not. If a compromised host feeds both models the same poisoned text, both can be fooled the same way. The second reviewer catches mistakes. The gate and my own approval are what actually stop a bad plan, and the executor is deliberately too simple to be talked into anything.

That is the real lesson so far. Let the AI do what it is good at, which is reading messy output and spotting what matters. Keep the part that changes systems small, boring and under my control.

← Back to all projects