8000 Join the tailnet with the ssh host key, no pre-auth key in sops by k2on · Pull Request #4 · k2on/os · GitHub
[go: up one dir, main page]

Skip to content

Join the tailnet with the ssh host key, no pre-auth key in sops - #4

Open
k2on wants to merge 2 commits into
cosmicfrom
tailnet-host-keys
Open

k2on wants to merge 2 commits into
cosmicfrom
tailnet-host-keys

Conversation

@k2on
@k2on k2on commented Oct 7, 2026 •
Copy link
Copy Markdown
Owner

Summary

Declarative tailnet joining without a headscale_preauth_key secret in sops. A host's identity is its ed25519 ssh host key, whose age recipient is already in the config as ark.hostKey. A VM's identity is its host: whatever is on the VM's disk its host can read anyway, so the host answers for it.

  • headscale's host (headscale-provision) mints one reusable pre-auth key per node with headscale preauthkeys create, encrypts it to the node's recipient with age, and keeps only the ciphertext under /var/lib/tailnet-keys/pub/, which nginx serves at https://vpn.<domain>/tailnet/<node>.age. The key id and recipient are kept beside it; a changed recipient expires the old key and mints a new one.
  • Every host runs tailnet-authkey at boot: it fetches its file, decrypts it with its host key (ssh-to-age -private-key, the same conversion sops-nix does) into /run/tailnet/<host>, and tailscaled-autoconnect uses that. It also fetches the keys of its guests (ark.tailnet.guests, encrypted to the host's recipient) and installs each at the file the guest reads. Retried while headscale does not serve them yet.
  • A VM sets ark.tailnet.keyFile to where its host leaves the key and waits for it. For sivrad that is /run/host-credentials/tailnet-authkey, in the live virtiofs share adam already uses for the Signal account, so the key shows up in the running VM whenever adam gets it.
  • The joining side is one module, flake.nixosModules.ark-tailnet. den.aspects.tailnet wraps it for hosts (recipient = ark.hostKey); the sivrad microVM imports it directly through specialArgs.
  • sivrad also gets an ssh host key of its own on a new ssh.img volume (/var/lib/ssh), so its ssh identity survives rebuilds. It is not used for the tailnet.
  • Dropped: the shared headscale_preauth_key secret (both declarations), the sqlite insert, and with it the dependence on headscale's legacy plaintext-key path (kept only "for backwards compatibility" since 0.28).

The ciphertexts are public by design: only the matching host key opens them, so joining as a node takes its host's ssh host key, exactly as with sops before.

Deploying

No order. just rebuild-ark is all adam and sivrad need: adam is already on the tailnet and keeps its node key, and both keep retrying until the vps serves their keys. The vps needs the new config once, whenever it gets deployed, since only headscale can mint keys. Deploy it before or after.

Afterwards, optional:

  • Expire the old shared key in headscale: headscale preauthkeys list, then headscale preauthkeys expire --id <id> for the legacy one. Already-joined nodes keep their node keys.
  • secrets/vars/headscale_preauth_key.yaml in the secrets repo is now unused and can be deleted.
  • The VM's ssh host key changes once (it is now persistent), so the laptop's known_hosts entry for sivrad.<tailnet domain> will need updating.

Not covered: cale still uses koonFeatureTailscale (interactive OIDC login), as it is a personal laptop rather than an ark host.

Verification

The flake could not be evaluated here (the secrets submodule and the den/nixpkgs inputs are not reachable from this session), so this is parse-checked only. Points worth a look on the first deploy: the headscale preauthkeys create -o json output has key and id fields as expected for 0.28, and age -d with the ssh-to-age -private-key identity opens a file encrypted to the ssh-to-age recipient.

🤖 Generated with Claude Code

https://claude.ai/code/session_01YEzZFR72jxE52YHecT3vc7

claude added 2 commits October 7, 2026 18:17
…in sops

A node's identity is now its ed25519 ssh host key, whose age recipient is
already in the config as ark.hostKey. headscale-provision mints one
reusable pre-auth key per node, encrypts it to that recipient and serves
the ciphertext from nginx under /tailnet/; at boot a node fetches its
file, decrypts it with its host key (ssh-to-age) and hands it to
`tailscale up`. The shared headscale_preauth_key secret, its sqlite
import and headscale's legacy plaintext-key path go away, and keys are
per node, so one can be expired on its own.

The joining side is one module, flake.nixosModules.ark-tailnet, which
den.aspects.tailnet wraps for hosts and the sivrad microVM imports
directly. The VM gets an ssh host key of its own on a small volume
(_vm.nix: sshDir, hostKey); its recipient is read off that volume after
its first boot and the host answers for it in ark.tailnet.nodes. Until
then the VM boots without joining.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YEzZFR72jxE52YHecT3vc7
…adam

A VM's disk is its host's to read, so a host key of its own buys the VM
nothing on the tailnet: headscale now encrypts sivrad's key to adam's
recipient (ark.tailnet.guests), adam's tailnet-authkey fetches it with
its own and leaves it in the live credentials share, and the VM waits
for it there (ark.tailnet.keyFile). No recipient to read off the VM, no
second deploy: `just rebuild-ark` is all adam and sivrad need, and the
vps can be deployed before or after; until it serves the keys, adam
stays on the tailnet as it is and sivrad keeps trying.

The VM keeps its own ssh host key on its volume for a stable ssh
identity, which is all it is for now.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YEzZFR72jxE52YHecT3vc7
k2on pushed a commit that referenced this pull request Oct 18, 2026
…behind Kanidm at sivrad.koon.us/browser' (#4) from sivrad/os:chrome-in-container into main
k2on pushed a commit that referenced this pull request Oct 18, 2026
…watchable over noVNC' (#4) from sivrad/os:chrome-in-container into main
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

0