Skip to content

Conversation

@inureyes
Copy link
Member

Summary

Fixes #117

The get_proxy_jump() function existed in the SSH config parser but was never called during connection establishment. This PR implements automatic ProxyJump directive resolution from ~/.ssh/config when the CLI -J option is not specified.

Changes

Core Implementation

  • src/executor/connection_manager.rs: Updated execute_on_node_with_jump_hosts() to resolve effective jump hosts by checking CLI option first, then falling back to SSH config ProxyJump
  • src/executor/parallel.rs: Added ssh_config field to ParallelExecutor and updated all constructors
  • src/commands/exec.rs: Added ssh_config field to ExecuteCommandParams and passed it to the executor
  • src/app/dispatcher.rs: Updated to pass SSH config through to execution commands
  • src/app/initialization.rs: Added determine_effective_jump_hosts() helper function with comprehensive unit tests

Documentation

  • docs/architecture/ssh-jump-hosts.md: Added new section documenting SSH config ProxyJump integration with examples and usage patterns

Priority Order

Jump host resolution now follows this priority:

  1. CLI -J option (highest priority) - Explicitly specified jump hosts
  2. SSH config ProxyJump directive - Per-host configuration from ~/.ssh/config
  3. None - Direct connection (no jump host)

Example Usage

Given this SSH config:

Host *.internal
    ProxyJump bastion.example.com

Host db.internal
    ProxyJump db-gateway.example.com

Now works automatically:

# Automatically uses bastion.example.com from SSH config
bssh -H web.internal "uptime"

# CLI option overrides SSH config
bssh -J custom-jump.example.com -H web.internal "uptime"

# Most specific SSH config pattern wins
bssh -H db.internal "uptime"  # Uses db-gateway.example.com

Testing

  • Added 4 unit tests in src/app/initialization.rs::tests:
    • test_determine_effective_jump_hosts_cli_takes_precedence
    • test_determine_effective_jump_hosts_falls_back_to_ssh_config
    • test_determine_effective_jump_hosts_no_jump_host
    • test_determine_effective_jump_hosts_wildcard_pattern
  • All tests pass
  • Code compiles without warnings (except existing keychain tests)

Benefits

  • Seamless integration with existing SSH workflows
  • Centralized jump host configuration
  • Per-host or wildcard pattern support
  • No need to specify -J for frequently accessed internal hosts
  • Compatible with standard OpenSSH configuration

…d (issue #117)

The get_proxy_jump() function existed but was never called during connection.
Now bssh automatically uses ProxyJump from ~/.ssh/config when connecting to hosts
that have it configured.

Priority order for jump host resolution:
1. CLI -J option (highest priority)
2. SSH config ProxyJump directive
3. None (direct connection)

Changes:
- Add ssh_config field to ExecutionConfig and ParallelExecutor
- Update execute_on_node_with_jump_hosts to resolve effective jump hosts
- Pass ssh_config through dispatcher to execution commands
- Add determine_effective_jump_hosts helper function
- Add comprehensive unit tests for jump host resolution
- Update documentation in docs/architecture/ssh-jump-hosts.md

The implementation resolves jump hosts per-node, allowing different nodes
to use different jump hosts based on their SSH config patterns.
@inureyes inureyes added type:bug Something isn't working priority:medium Medium priority issue status:review Under review labels Dec 19, 2025
This commit extends the SSH config ProxyJump integration to file
transfer operations (upload/download), addressing the consistency
issue where command execution respected SSH config ProxyJump but
file transfers did not.

Changes:
- Add ssh_config parameter to upload_to_node, download_from_node,
  and download_dir_from_node functions in connection_manager.rs
- Apply the same jump host resolution logic (CLI precedence over
  SSH config) for all file transfer operations
- Update execution_strategy.rs task functions to accept ssh_config
- Update parallel.rs to pass ssh_config to file transfer tasks

This ensures consistent behavior where users configuring ProxyJump
in their ~/.ssh/config will have it applied to both command
execution and file transfers automatically.
Completes the SSH config ProxyJump integration for the upload and
download CLI commands by adding ssh_config to FileTransferParams.

Changes:
- Add ssh_config field to FileTransferParams struct in upload.rs
- Update dispatcher.rs to pass ctx.ssh_config in FileTransferParams
  for both upload and download commands
- Update upload_file() to call executor.with_ssh_config()
- Update download_file() to call executor.with_ssh_config()
- Update download_dir_from_node() call to pass params.ssh_config

This ensures that `bssh upload` and `bssh download` commands now
properly respect ProxyJump directives from ~/.ssh/config.
Adds 11 new unit tests for the SSH config ProxyJump resolution logic
in connection_manager.rs:

Test Coverage:
- CLI jump hosts precedence over SSH config
- SSH config ProxyJump fallback when CLI not specified
- No jump hosts when neither CLI nor SSH config specifies one
- No jump hosts when SSH config is not provided
- Multi-hop ProxyJump chains (comma-separated)
- ProxyJump with port specification (host:port)
- ProxyJump with user and port (user@host:port)
- Wildcard pattern matching (*.internal.example.com)
- Unmatched hosts returning no ProxyJump
- ProxyJump "none" value for disabling jump
- Complex multi-hop chains with mixed formats

Also adds a `resolve_effective_jump_hosts` helper function that
encapsulates the priority logic for easier testing.
@inureyes inureyes merged commit 08b21e6 into main Dec 19, 2025
2 checks passed
@inureyes inureyes deleted the fix/issue-117-proxy-jump-ssh-config branch December 19, 2025 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

priority:medium Medium priority issue status:review Under review type:bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix: SSH config ProxyJump directive parsed but never applied during connection

2 participants