plumbing: transport/ssh, honor custom host key callbacks#2145
Open
puneetdixit200 wants to merge 3 commits into
Open
plumbing: transport/ssh, honor custom host key callbacks#2145puneetdixit200 wants to merge 3 commits into
puneetdixit200 wants to merge 3 commits into
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Note
Copilot was unable to run its full agentic suite in this review.
Updates SSH transport connection setup to avoid relying on known_hosts when callers provide a custom HostKeyCallback, and adds a regression test to ensure missing known_hosts doesn’t block connection attempts.
Changes:
- Skip deriving
HostKeyAlgorithmsfromknown_hostswhen a customHostKeyCallbackis provided. - Add a test covering custom host key callbacks with a missing
known_hostspath.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| plumbing/transport/ssh/ssh.go | Adjusts host key algorithm derivation logic to only use known_hosts for the default callback path. |
| plumbing/transport/ssh/ssh_test.go | Adds a regression test ensuring missing known_hosts does not prevent dialing when using a custom callback. |
b44c5bf to
1afa266
Compare
Author
|
Rebased this branch onto current Verified locally:
|
1afa266 to
2ca9bfd
Compare
Author
|
Rebased this onto current main. I rechecked the SSH transport changes with:
|
…t#1234 When a caller supplies HostKeyCallback, avoid probing default known_hosts to derive HostKeyAlgorithms. Document the behavior and keep the regression test serialized around its temporary known_hosts override. Assisted-by: OpenAI GPT-5 <[email protected]> Signed-off-by: Puneet Dixit <[email protected]>
Let the custom callback regression inject a missing known_hosts path on the transport instance instead of mutating SSH_KNOWN_HOSTS process-wide. Assisted-by: OpenAI GPT-5 <[email protected]> Signed-off-by: Puneet Dixit <[email protected]>
Keep deriving HostKeyAlgorithms from known_hosts for custom host key callbacks when known_hosts is available. Missing known_hosts files are ignored only for custom callbacks so callers can still provide their own verifier without requiring local known_hosts state. Assisted-by: OpenAI GPT-5 <[email protected]> Signed-off-by: Puneet Dixit <[email protected]>
2ca9bfd to
36fa61b
Compare
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
HostKeyCallbackconfigurations usable when known_hosts files are missingHostKeyAlgorithmsfor custom callbacks when known_hosts is available and the caller leavesHostKeyAlgorithmsemptySSH_KNOWN_HOSTSmutation in regression tests by injecting known_hosts files through the transportFixes #1234
Validation
go test ./plumbing/transport/ssh -run TestSSHTransport_CustomHostKeyCallbackWithoutKnownHosts -count=1failed withunable to find any valid known_hosts file, set SSH_KNOWN_HOSTS env variableinstead of reaching the dialergo test ./plumbing/transport/ssh -count=1go test ./plumbing/transport/... -count=1go test -race ./plumbing/transport/ssh ./plumbing/transport/ssh/knownhosts -count=1make validate-lintgit diff --checkandgit diff HEAD^ --checkgo test ./plumbing/transport/sshandgit diff --check upstream/main...HEADAlso ran
make test, which executesgo test -race ./.... The touched SSH/transport packages passed in that run, but the full target failed in the existing localplumbing/format/gitignoreconformance oracle against Apple Git 2.39.5 forfoo**/barmatchingfoobar/foobar/baz; that package is outside this change.AI assistance disclosure
OpenAI GPT-5 assisted with issue/code navigation, drafting the focused tests and patches, and selecting validation commands. I reviewed the final diff and validation output before submitting.