Skip to content

Verify and pin the stock image's host key during install - #36

Open
byjpr wants to merge 1 commit into
claude/admiring-planck-25cvzffrom
claude/fix-12-install-hostkey
Open

byjpr wants to merge 1 commit into
claude/admiring-planck-25cvzffrom
claude/fix-12-install-hostkey

Conversation

@byjpr

@byjpr byjpr commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Closes #12

Changes

  • Verify first. just install scans the stock image's ed25519 host key, shows its fingerprint, and requires you to paste the matching fingerprint from the provider's web console before anything is uploaded.
    • The console shows it in cloud-init's "SSH HOST KEY FINGERPRINTS" boot output, or via ssh-keygen -lf … after logging in there.
    • INSTALL_HOST_FINGERPRINT=SHA256:… skips the prompt.
    • Typing trust skips verification explicitly, with a warning.
  • Pin it. The verified key is pinned for:
    • detect-machine.sh, which no longer uses accept-new;
    • nixos-anywhere. It always passes -o UserKnownHostsFile=/dev/null -o StrictHostKeyChecking=no, and OpenSSH uses the first value given for an option, so --ssh-option can't override it. An ssh wrapper placed first on PATH puts the pinned options in front. nixos-anywhere's Nix wrapper appends its own openssh last on PATH, so the wrapper is the one used.
  • The nixos-anywhere kexec installer keeps the stock image's host keys (nixos-anywhere relies on this), so the pin holds through the installer phase too. The server's private host key, which also decrypts all secrets, is only ever sent to the verified machine.

Testing

I ran a local sshd and called the wrapper with nixos-anywhere's exact options appended:

Pinned key Result
correct key connected
a different key Host key verification failed.

All 5 provider example systems build. nixfmt, shellcheck and tofu validate pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_01G22o7QQ17GRtkCqpJNFr9B


Generated by Claude Code

just install now shows the stock image's ed25519 host key fingerprint and
requires it to match the one from the provider's console (or
INSTALL_HOST_FINGERPRINT) before uploading anything. The key is pinned for
detect-machine.sh and for nixos-anywhere: since nixos-anywhere passes
StrictHostKeyChecking=no and OpenSSH uses the first value of an option, an
ssh wrapper earlier in PATH puts the pinned options first. The kexec
installer keeps the stock host keys, so the pin covers the whole install.

Closes #12

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Claude-Session: https://claude.ai/code/session_01G22o7QQ17GRtkCqpJNFr9B
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.

[Medium] First install trusts the stock image's SSH host key blindly, then uploads the server's private host key

2 participants