Skip to content

feat(ssh): wire BindAddress and interface from sshconfig to net.Dialer - #376

Merged
kke merged 1 commit into
mainfrom
ssh-config-bind-address
Jun 6, 2026
Merged

kke merged 1 commit into
mainfrom
ssh-config-bind-address

Conversation

@kke

@kke kke commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Sets LocalAddr on the net.Dialer in Connect() based on the ssh config BindAddress (parsed as IP) or BindInterface (first global-unicast address from the interface, respecting AddressFamily). Both are no-ops when unset.

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 wires OpenSSH-style BindAddress / BindInterface from sshconfig into the SSH connection path by setting net.Dialer.LocalAddr during Connection.Connect(), enabling explicit source-address binding for outbound SSH connections.

Changes:

  • Added selectBindAddr helper to pick the first global-unicast address from an interface that matches the requested dial family (tcp, tcp4, tcp6).
  • Added Connection.localAddr() to derive net.Dialer.LocalAddr from BindAddress (IP) or BindInterface (interface address), with trace logging and safe fallbacks.
  • Added unit tests for selectBindAddr and basic localAddr behavior.

Reviewed changes

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

File Description
protocol/ssh/connection.go Introduces local bind address selection and applies it to the net.Dialer used by Connect().
protocol/ssh/connection_test.go Adds tests covering address selection logic and BindAddress / missing-interface handling.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread protocol/ssh/connection.go Resolved
@kke
kke force-pushed the ssh-config-bind-address branch from e656627 to 4e96a65 Compare June 6, 2026 08:48
@kke
kke requested a review from Copilot June 6, 2026 08:49

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 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread protocol/ssh/connection_test.go Resolved
@kke
kke force-pushed the ssh-config-bind-address branch from 4e96a65 to 76231a9 Compare June 6, 2026 09:16
@kke
kke requested a review from Copilot June 6, 2026 09:16

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 2 out of 2 changed files in this pull request and generated 1 comment.

Comment thread protocol/ssh/connection.go Resolved
…ialer

Sets LocalAddr on the net.Dialer in Connect() based on the ssh config
BindAddress (parsed as IP) or BindInterface (first global-unicast address
from the interface, respecting AddressFamily). Both are no-ops when unset.

Signed-off-by: Kimmo Lehto <klehto@mirantis.com>
@kke
kke force-pushed the ssh-config-bind-address branch from 76231a9 to c02f5f9 Compare June 6, 2026 09:41
@kke
kke requested a review from Copilot June 6, 2026 09: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 2 out of 2 changed files in this pull request and generated no new comments.

@kke
kke marked this pull request as ready for review June 6, 2026 10:01
@kke
kke merged commit b97bc35 into main Jun 6, 2026
13 checks passed
@kke
kke deleted the ssh-config-bind-address branch June 6, 2026 10:01
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