Skip to main content
TACAVAR
•Build in Public

Cross-Server Deploys Without Shared Root SSH Keys

How Tacavar's deploy_gate.sh lets one droplet trigger whitelisted jobs on another without sharing root SSH keys — least privilege, full audit logging.

Sharing root SSH keys between servers was the obvious answer. I built a whitelist instead.

At Tacavar, the Bailian droplet runs agent workloads that periodically need to act on the primary droplet: trigger a deploy, post an Instagram reel, write a video brief. Those are cross-server command execution calls, and the standard playbook is to hand the calling machine an SSH key with enough privilege to do whatever it needs. I've done it that way before. I won't again.

The Problem: Bailian Needs to Trigger Jobs on the Primary Droplet

Bailian is a worker. Its job is to orchestrate agent tasks, and some of those tasks terminate in actions that only make sense on the primary droplet — the machine that holds the deploy pipeline, the publishing credentials, and the content tooling. When a workflow finishes a draft, Bailian needs the primary to pull and redeploy. When a reel is ready, the primary is the machine with the Instagram publishing path. When a brief needs writing, the primary owns the tooling.

These calls are small in shape but broad in variety: trigger deploy, post reel, write brief. That's an RPC problem, not a shell problem. The real question was what transport to use and, more importantly, what trust model came attached to it.

Why Shared SSH Keys Fail the Blast Radius Test

The conventional move: generate a keypair, drop the private half on Bailian, add the public half to the primary's authorized_keys, done. Bailian can now run anything on the primary — and that's the problem. If Bailian is ever compromised, the attacker inherits root on the machine that deploys everything, holds publishing credentials, and touches every production surface. One compromised worker becomes total compromise.

That fails the blast radius test. This is exactly why ssh key security alternatives get taken seriously: shared credentials are an all-or-nothing trust decision. Least privilege server architecture demands the opposite — the caller should be able to do exactly what it needs, nothing more, and every one of those things should be observable. An unscoped root key hands over all the power and none of the boundaries. I wanted most of the power with a fraction of the blast radius.

deploy_gate.sh: Accepting Command Names, Not Raw Bash

So I built deploy_gate.sh — a whitelist-based dispatcher that lives on the primary droplet. Bailian connects over SSH using a dedicated deploy key, but that key is locked to a single forced command via authorized_keys: deploy_gate.sh. The gate reads one argument from the connection — a command name — and checks it against a hardcoded whitelist. If the name matches, the gate dispatches to the corresponding implementation and runs it under sudo with a scoped sudoers entry. If it doesn't match, the gate refuses and logs the refusal.

The critical design decision: deploy_gate.sh accepts command names, never raw bash. Bailian can't send cat /etc/shadow, a pipe chain, or an interpolated string. It can send deploy. The gate resolves that name to a fixed implementation with validated arguments. That's the whole trick behind the whitelist dispatcher devops pattern — the remote caller picks from a menu, and the menu is the security boundary. Cross-server command execution becomes a closed set instead of an open channel.

The Whitelist Doubles as Living Documentation

The side effect I didn't expect to value this much: reading deploy_gate.sh tells you exactly what Bailian is allowed to do on the primary. No archaeology through sudoers files, no grepping shell histories, no reverse-engineering trust relationships. The whitelist is the permission model, in one file, in plain sight.

That matters operationally. When I audit what Bailian can reach, I read one script. When a new teammate asks what the worker can touch, I point them at the same script. When I want to revoke a capability, I delete a line. In a least privilege server architecture, boundaries should be legible, and this dispatcher makes them legible by construction. Documentation that drifts out of date is worse than nothing; a whitelist that gates actual execution can't drift, because it is the execution.

Audit Logging Every Single Dispatched Call

The gate writes every call to an audit log before it runs: timestamp, command name, arguments, calling key, and exit code once it finishes. Refused names get logged too, which matters more — a refusal is either a bug in a workflow or someone probing the boundary, and I want to know immediately either way.

Audit logging remote commands turns the dispatcher from a trust mechanism into an observable system. When a deploy fires at an odd hour, I can answer who triggered it, what arguments it carried, and what the result was without touching shell history or SSH logs. That's the difference between "we think Bailian only runs whitelisted things" and "here is the complete record of what Bailian ran." Combined with the whitelist, it closes the loop: limited capability, fully observed.

Adding New Commands: instagram_post and the Growing List

The whitelist started with deploy. Days into production, a workflow needed to publish reels directly from Bailian's output, so I wrote the implementation, tested it, and added instagram_post to the whitelist. The entire rollout was one line and a reload.

Since then the list has grown with the workflows: domain_pending for certificate status checks, pip_install_* patterns for scoped dependency installs, and more as Bailian's responsibilities expand. Each addition is explicit, reviewed, and instantly documented by its own existence in the file. That's the long-term payoff of this design — capability growth at the speed of editing a whitelist, with none of the quiet privilege creep that comes from loosening an SSH key "just this once."

Shared root SSH keys are the obvious answer to cross-server command execution. They're also an unbounded bet that neither machine ever gets compromised. A whitelist dispatcher, scoped sudoers entries, and a complete audit trail deliver the same reach with hard boundaries — and on Tacavar's infrastructure, hard boundaries are the default.

Tacavar runs multi-droplet agent infrastructure under strict least-privilege rules. See how the deploy gate fits the broader system at tacavar.com