Per-machine host identity on /data: SSH host keys and machine-id never ship baked - #917
Merged
Merged
Conversation
Both were baked into the appliance image at build time (openssh-server's and systemd's own postinst), making them extractable from a published release and identical across every machine flashed from one — and silently rotating on any image rebuild (#894, #895). The image now ships neither: no ssh_host_* files, and a 0-byte machine-id so systemd runs its own documented first-boot semantics. Both are then generated once, at boot, into /data — the single persistence root Tor's onion identity already lives on: - SSH: a baked ssh.service drop-in (RequiresMountsFor=/data) generates a host key into /data/ssh before sshd starts, and sshd_config.d points HostKey there. The debug variant's baked authorized_keys stays untouched (user auth, out of scope). - machine-id: a new early oneshot unit (pithead-machine-id.service, ordered before systemd-networkd and systemd-journal-flush) restores the persisted id from /data, or adopts and persists this boot's id on a genuinely first boot. The installer's reinstall tiers and the appliance's own factory-reset both already destroy or preserve /data/pithead wholesale, so host identity follows the same keep/wipe classification as everything else there with one small addition (pithead-install now also clears /data/ssh, which sits outside the pithead/ tree the existing wipe already rm -rf's). tests/os/verify-image.sh asserts the built image ships neither identity concrete; tests/os/run.sh asserts host identity survives an A/B update and machine-id stays stable across a plain reboot. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
An empty /etc/machine-id on a volatile /etc upper makes EVERY boot a first boot to systemd, and PID 1 applies preset-all (enable-only) on first boot. Debian ships no preset files and systemd's no-preset fallback is enable — a release image would quietly re-enable the deliberately-disabled ssh.service each power cycle. Bake a blanket disable-* preset so the pass is a no-op, and mask systemd-firstboot (would re-run per boot and can prompt on console for unset basics). Also harden the machine-id restore for both PID-1 shapes (direct write into the writable overlay upper vs read-only bind mount from /run): drop a bind mount if one exists before writing, and correct the comment that described only the read-only shape. verify-image.sh now pins the preset file and the firstboot mask alongside the identity assertions. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
…iew) Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This was referenced Aug 13, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #894, closes #895.
Both identities were generated by their packages' postinst inside the Docker build: extractable from any published release, identical across every machine flashed from it, silently rotated whenever the apt layer rebuilt. One mechanism now carries both, per the issues' option 1:
os/rootfs/Dockerfile):ssh_host_*deleted,/etc/machine-idshipped empty; sshd pointed at/data/sshviasshd_config.d(Debian trixie's stock config Includes it, and one explicit HostKey disables the compiled-in default paths).ssh.servicedrop-in (RequiresMountsFor=/data) runs a generate-if-missing ExecStartPre — ed25519 into/data/ssh, tight modes, idempotent, stale-partial-safe. Identity survives A/B swaps and rebuilds; the debug variant's baked authorized_keys is user auth and untouched.DefaultDependencies=no,Before=systemd-networkd.service systemd-journal-flush.service) restores the persisted id from/data/pithead/machine-id— before the DHCP DUID and the journal directory key observe it — or adopts+persists this boot's id on a true first boot. Handles both PID-1 shapes (direct overlay write and ro bind mount).ssh.serviceon release images. A bakeddisable *preset neutralizes that pass andsystemd-firstbootis masked. verify-image pins both./data/ssh(machine-id already goes with the pithead tree);all/factory-reset destroy everything as before — a handed-over machine keeps nothing.make lint+ full suite green (stack 2171/0, dashboard 1760, verify-image and run.sh additions shellchecked). The KVM battery run right after merge is the live proof for the new asserts. Verifier + security review passed; ponytail cut two env knobs nothing set.🤖 Generated with Claude Code