security: SSH host key verification with TOFU#10
Merged
Conversation
Replace StrictHostKeyChecking=no with accept-new mode using a pixels-managed known_hosts file at ~/.config/pixels/known_hosts. SSH connections now use the container hostname (px-<name>) instead of IP to avoid stale entries from IP reuse across container churn. Lifecycle methods (Create, Start, RestoreSnapshot, Delete) clean up both hostname and IP entries from known_hosts to prevent false rejections. Opt out via strict_host_keys = false under [ssh] config. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
⬇️ Go test coverage decreased from 30.3% to 25.1% compared to ec55944
|
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
- Add NewConnConfig constructor for secure-by-default ConnConfig - Rename KnownHostsFile → KnownHostsPath (Go convention) - Return *tnapi.VirtInstance from ensureRunning to avoid redundant API calls - Rewrite RemoveKnownHost using golang.org/x/crypto/ssh instead of ssh-keygen - Add defaultKnownHostsPath() fallback so Args() is always secure - Replace silent error swallowing (_ = err) with warnf logging - Fix provision.NewRunner to accept knownHostsPath parameter Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Replace golang.org/x/crypto/ssh ParseKnownHosts loop with a simple bytes.HasPrefix filter. We control the known_hosts file format, so full crypto parsing is unnecessary. Removes the x/crypto dependency. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
DRY up the repeated remove-known-hosts-then-wait-ssh pattern across Create, Start, RestoreSnapshot, and Delete in backend.go. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
StrictHostKeyChecking=nowithaccept-newmode using a pixels-managed~/.config/pixels/known_hostsfile — auto-accepts new hosts, rejects changed keys (MITM protection)px-<name>) instead of IP to avoid stale known_hosts entries from IP reuse across container churnTest plan
go build && go test ./... && go vet ./...all passpixels create <name>creates a container and records its host key in~/.config/pixels/known_hostspixels exec <name> -- hostnameconnects without promptspixels destroy <name>removes the entry from known_hostsstrict_host_keys = falseunder[ssh]in config falls back to old behavior🤖 Generated with Claude Code