From ab8c63531ca4a5d8eb185fcdafbe02122649416b Mon Sep 17 00:00:00 2001 From: tv Date: Sat, 21 Nov 2026 15:09:49 +0000 Subject: run-firecracker-vm: secrets, --secret NAME=FILE and fc.secrets Secrets for a guest, like API keys, had no way in but the store or /xchg, which other VMs started in the same directory see. Now a layer declares the secrets its guest needs (fc.secrets.NAME, with where it goes, default /run/secrets/NAME, and whose it is, default root's, 0400), and the run script gets them with --secret NAME=FILE (FILE read once, so a pipe will do), refusing to start the guest without the declared ones. Like the SSH host key, it copies them into its private temporary directory and serves that via 9P on vsock port 568, to that guest only; there, fc-secrets copies them into place, before sysinit.target (so before any service with the default dependencies), but after the users get created, and unmounts the share again. A secret the guest doesn't declare goes to /run/secrets/NAME, root's, with a warning. --- README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'README.md') diff --git a/README.md b/README.md index 30dc439..303f2a7 100644 --- a/README.md +++ b/README.md @@ -156,6 +156,26 @@ Who may log in goes in a layer, e.g.: A guest's address is its VM's, by name (`vms`, see host setup), or else its tap's own (see `fc-egress vms`). +Secrets, like API keys, come from the host at boot, too, never through +the store or `/xchg` (which other VMs started in the same directory +see): a layer declares what it needs, where it goes (default: +`/run/secrets/NAME`), and whose it is (default: root's, 0400): + +```nix +{ fc.secrets."hermes.env" = { owner = "hermes"; }; } +``` + +and the run script, which doesn't start the guest without them, gets +them with `--secret NAME=FILE` (FILE read once, so a pipe will do): + +```sh +./result/bin/run-firecracker-vm --secret hermes.env=<(pass show hermes/env) +``` + +They're only that guest's, and only in its memory (`/run`), until it +stops; to change one, restart the guest. A secret the guest doesn't +declare ends up in `/run/secrets/NAME`, root's, with a warning. + The guest's system can be built in layers, each a NixOS module on top of the ones before (the first on top of the base system): -- cgit v1.3.1