Repository navigation
feat(ssh): wire HostKeyAlias from sshconfig for known_hosts lookup - #379
Merged
Merged
Conversation
There was a problem hiding this comment.
Pull request overview
This PR adds support for HostKeyAlias from ssh_config so that known_hosts lookups and newly appended entries use the configured alias (instead of the actual hostname/IP), and it disables CheckHostIP when an alias is active to align with OpenSSH behavior.
Changes:
- Add
hostkey.WithAlias(...)wrapper to rewrite hostnames/addresses used byknown_hostsverification and storage. - Skip
CheckHostIPwhenHostKeyAliasis set to avoid incorrect IP verification. - Add tests validating alias-based lookup, storage, and mismatch handling.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| protocol/ssh/hostkey/callbacks.go | Introduces alias-aware HostKeyCallback wrapper and supporting address wrapper. |
| protocol/ssh/hostkey/callbacks_test.go | Adds tests ensuring known_hosts lookup/storage works via alias and errors on mismatched keys. |
| protocol/ssh/connection.go | Wires HostKeyAlias into hostkey callback setup and disables CheckHostIP when alias is set. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
When HostKeyAlias is set, known_hosts lookups and new-entry storage use the alias instead of the actual hostname/IP. CheckHostIP is suppressed when an alias is active, matching OpenSSH behaviour. Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
kke
marked this pull request as ready for review
June 7, 2026 18:22
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.
When HostKeyAlias is set, known_hosts lookups and new-entry storage use the alias instead of the actual hostname/IP. CheckHostIP is suppressed when an alias is active, matching OpenSSH behaviour.