setup-machine: Add and deploy new host key automatically #8

Open
opened 2026-05-20 07:07:31 +00:00 by barnett · 0 comments
Owner

Right now, when setting up a new machine that will require secrets immediately, one must generally:

  1. Run age-keygen -pq -o newhost.keys.txt to get the private key.
  2. Add the public key from age-keygen -y newhost.keys.txt to .sops.yaml .
  3. Create or rotate the secrets in the new host directory based on the new entries in .sops.yaml.
  4. Stage newhost.keys.txt in a small extra-files tree under etc/age.
  5. Pass --extra-files to nixos-anywhere to ensure it gets copied.

This should be automatable:

  1. Let the user create new secrets with only their user key at first when configuring a new host.
  2. On first deployment, a script should:
    1. Generate a key into a temporary folder following the etc/age structure.
    2. Add it to .sops.yaml with yq for the new host folder.
    3. Run sops updatekeys to rotate in the new key.
    4. Call nixos-anywhere while passing the temporary folder as --extra-files.
    5. Destroy the temporary folder afterwards.
Right now, when setting up a new machine that will require secrets immediately, one must generally: 1. Run `age-keygen -pq -o newhost.keys.txt` to get the private key. 2. Add the public key from `age-keygen -y newhost.keys.txt` to `.sops.yaml` . 3. Create or rotate the secrets in the new host directory based on the new entries in `.sops.yaml`. 4. Stage newhost.keys.txt in a small extra-files tree under `etc/age`. 5. Pass `--extra-files` to `nixos-anywhere` to ensure it gets copied. This should be automatable: 1. Let the user create new secrets with only their user key at first when configuring a new host. 2. On first deployment, a script should: 1. Generate a key into a temporary folder following the `etc/age` structure. 2. Add it to `.sops.yaml` with `yq` for the new host folder. 3. Run `sops updatekeys` to rotate in the new key. 4. Call `nixos-anywhere` while passing the temporary folder as `--extra-files`. 5. Destroy the temporary folder afterwards.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
kebado.net/nixos-servers#8
No description provided.