Skip to content

Conversation

@inureyes
Copy link
Member

Summary

Following up on #167, this PR adds support for referencing SSH config Host aliases in bssh's jump_host configuration. This allows users to leverage existing ~/.ssh/config entries with all their settings.

New Formats Supported

Simple string with @ prefix:

clusters:
  internal:
    jump_host: "@bastion"  # References SSH config Host alias

Structured format:

clusters:
  internal:
    jump_host:
      ssh_config_host: bastion  # References SSH config Host alias

How It Works

When an SSH config reference is used, bssh resolves the alias from ~/.ssh/config and extracts:

  • HostName (or uses alias as hostname if not specified)
  • User
  • Port
  • IdentityFile (first one, used as SSH key for the jump host)

Example

~/.ssh/config:

Host bastion
    HostName bastion.example.com
    User jumpuser
    Port 2222
    IdentityFile ~/.ssh/bastion_key

bssh config.yaml:

clusters:
  internal:
    nodes:
      - host: internal.private
    jump_host: "@bastion"

This is equivalent to:

    jump_host:
      host: bastion.example.com
      user: jumpuser
      port: 2222
      ssh_key: ~/.ssh/bastion_key

Changes

  • Add SshConfigHostRef variant to JumpHostConfig enum
  • Add is_ssh_config_ref() and ssh_config_host() methods to JumpHostConfig
  • Add resolve_jump_host() and resolve_jump_host_connection() to SshConfig
  • Add get_jump_host_with_key_and_ssh_config() for full SSH config resolution
  • Update example-config.yaml with SSH config reference examples
  • Add 15 new tests for SSH config reference functionality

Test Plan

  • New tests for SSH config reference parsing
  • New tests for SSH config resolution
  • New tests for fallback when alias not found
  • Backward compatibility with existing formats
  • All 33 jump_host_config tests pass
  • Clippy passes with no warnings

Closes #170

Add support for referencing SSH config Host aliases in bssh's jump_host
configuration. This allows users to leverage existing SSH config entries
with all their settings (HostName, User, Port, IdentityFile).

New formats supported:
- Simple string with @ prefix: `jump_host: "@Bastion"`
- Structured format: `jump_host: { ssh_config_host: "bastion" }`

When an SSH config reference is used, bssh resolves the alias from
~/.ssh/config and extracts:
- HostName (or uses alias as hostname if not specified)
- User
- Port
- IdentityFile (first one, used as SSH key for the jump host)

Changes:
- Add SshConfigHostRef variant to JumpHostConfig enum
- Add is_ssh_config_ref() and ssh_config_host() methods to JumpHostConfig
- Add resolve_jump_host() and resolve_jump_host_connection() to SshConfig
- Add get_jump_host_with_key_and_ssh_config() for full SSH config resolution
- Update example-config.yaml with SSH config reference examples
- Add 15 new tests for SSH config reference functionality

Closes #170
@inureyes inureyes added the type:enhancement New feature or request label Jan 28, 2026
@inureyes inureyes merged commit b2be72c into main Jan 28, 2026
1 check failed
@inureyes inureyes deleted the feature/issue-170-ssh-config-host-alias branch January 28, 2026 05:38
@inureyes inureyes self-assigned this Jan 28, 2026
@inureyes inureyes added status:done Completed priority:high High priority issue labels Jan 28, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:high High priority issue status:done Completed type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Support SSH config Host alias reference in jump_host configuration

2 participants