Skip to content

feat(ssh): wire HostKeyAlias from sshconfig for known_hosts lookup - #379

Merged
kke merged 1 commit into
mainfrom
cfg-host-key-alias
Jun 7, 2026
Merged

kke merged 1 commit into
mainfrom
cfg-host-key-alias

Conversation

@kke

@kke kke commented Jun 7, 2026

Copy link
Copy Markdown
Contributor

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.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 by known_hosts verification and storage.
  • Skip CheckHostIP when HostKeyAlias is 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.

Comment thread protocol/ssh/hostkey/callbacks.go Resolved
@kke
kke force-pushed the cfg-host-key-alias branch from 783ddf2 to 8f79607 Compare June 7, 2026 08:31
@kke
kke requested a review from Copilot June 7, 2026 08:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.

Comment thread protocol/ssh/hostkey/callbacks.go Resolved
Comment thread protocol/ssh/connection.go Resolved
@kke
kke force-pushed the cfg-host-key-alias branch from 8f79607 to 047552b Compare June 7, 2026 08:39
@kke
kke requested a review from Copilot June 7, 2026 08:39

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread protocol/ssh/hostkey/callbacks.go Resolved
@kke
kke force-pushed the cfg-host-key-alias branch from 047552b to f58a6ff Compare June 7, 2026 10:11
@kke
kke requested a review from Copilot June 7, 2026 10:11

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread protocol/ssh/hostkey/callbacks.go Resolved
Comment thread protocol/ssh/hostkey/callbacks.go Resolved
@kke
kke force-pushed the cfg-host-key-alias branch from f58a6ff to 006ddcd Compare June 7, 2026 10:29
@kke
kke requested a review from Copilot June 7, 2026 10:29

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 1 comment.

Comment thread protocol/ssh/hostkey/callbacks.go Resolved
@kke
kke force-pushed the cfg-host-key-alias branch from 006ddcd to 579b18d Compare June 7, 2026 17:41
@kke
kke requested a review from Copilot June 7, 2026 17:41

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated 2 comments.

Comment thread protocol/ssh/hostkey/callbacks.go Resolved
Comment thread protocol/ssh/hostkey/callbacks_test.go Resolved
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
kke force-pushed the cfg-host-key-alias branch from 579b18d to 6bd423a Compare June 7, 2026 18:13
@kke
kke requested a review from Copilot June 7, 2026 18:14

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 4 out of 4 changed files in this pull request and generated no new comments.

@kke
kke marked this pull request as ready for review June 7, 2026 18:22
@kke
kke merged commit 11cfc65 into main Jun 7, 2026
13 checks passed
@kke
kke deleted the cfg-host-key-alias branch June 7, 2026 18:23
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.

2 participants