Skip to content

feat(hostkey): make tofu trust first-seen keys and add prompt shortcuts - #36

Merged
ntwrknrd merged 1 commit into
mainfrom
feat/hostkey-tofu-shortcuts
Oct 28, 2026
Merged

ntwrknrd merged 1 commit into
mainfrom
feat/hostkey-tofu-shortcuts

Conversation

@ntwrknrd

Copy link
Copy Markdown
Owner

Summary

ssh.security.host_key_policy: tofu only switched Accept once to accept-new; every first connection still showed the host-key prompt.

  • TOFU: with tofu, a first-seen key is appended to ~/.ssh/known_hosts without prompting, and nssh prints the host and fingerprint to stderr. Changed keys still go through the existing warning prompt. This also works for captured command runs, which previously failed without an interactive prompt.
  • Shortcuts: the new-key prompt accepts Enter (reject, the default), o (accept once), and a (accept always). Arrow keys still work, and filtering is off so letters stay shortcuts. The changed-key prompt keeps no single-key acceptance, since a stray key there would trust a possibly hostile key.

Changes

  • internal/connect/hostkey_prepare.go: TOFU path in runHostKeyPreparation.
  • internal/ui/prompts.go: SelectIndexWithShortcuts, a huh select wrapped to intercept shortcut keys.
  • internal/connect/hostkey.go: new-key prompt labels and shortcuts.
  • Docs in the nssh skill reference and example_config.yaml.

Verification

  • New tests for shortcut selection and TOFU (new key trusted without prompt; changed key still prompts).
  • make container-test passes.

host_key_policy: tofu only changed Accept once, so every new host still
prompted. It now adds a first-seen key to known_hosts without asking and
prints the fingerprint; changed keys still prompt. The new-key prompt also
accepts Enter to reject, o to accept once, and a to accept always.
@ntwrknrd
ntwrknrd merged commit bf4b66d into main Oct 28, 2026
3 checks passed
@ntwrknrd
ntwrknrd deleted the feat/hostkey-tofu-shortcuts branch October 28, 2026 17:29
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.

1 participant