Skip to content

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

@inureyes

Description

@inureyes

Problem / Background

The SSH config file (~/.ssh/config) ProxyJump directive is correctly parsed but never applied during connection establishment. The get_proxy_jump() function exists in the codebase but is never called, meaning connections completely ignore the ProxyJump setting from SSH config.

This breaks compatibility with OpenSSH behavior where users expect ProxyJump directives to work automatically.

Current Behavior

  • bssh parses ~/.ssh/config and reads ProxyJump directives correctly
  • SshHostConfig.proxy_jump field is populated during parsing
  • get_proxy_jump(hostname) method exists in src/ssh/ssh_config/mod.rs:142
  • However, this method is never called anywhere in the codebase
  • Connections ignore the ProxyJump setting from SSH config

Expected Behavior

When connecting to a host that has ProxyJump configured in ~/.ssh/config, bssh should automatically use that jump host. This should work similarly to OpenSSH's behavior.

Example SSH Config:

Host internal-server
    HostName 192.168.1.100
    User admin
    ProxyJump bastion.example.com

Host bastion.example.com
    User jumpuser
    Port 22

When running bssh internal-server 'ls', bssh should automatically use bastion.example.com as the jump host.

Root Cause

The function get_proxy_jump() is defined but never integrated into the connection flow:

// src/ssh/ssh_config/mod.rs:142-144
pub fn get_proxy_jump(&self, hostname: &str) -> Option<String> {
    resolver::get_proxy_jump(&self.hosts, hostname)
}

This method needs to be called during connection establishment, and the returned jump host spec should be passed to the jump host chain.

Proposed Solution

  1. In src/app/initialization.rs or connection setup code, call ssh_config.get_proxy_jump(hostname)
  2. Merge SSH config ProxyJump with CLI -J option (CLI should take precedence)
  3. Pass the resolved jump host to the connection logic

Priority Order for Jump Host Resolution:

  1. CLI -J option (highest priority)
  2. SSH config ProxyJump directive
  3. bssh config.yaml jump_host (when implemented - see feat: Add jump_host field support in config.yaml #115)

Acceptance Criteria

  • get_proxy_jump() is called during connection setup for each target host
  • ProxyJump from SSH config is used when no CLI -J option is specified
  • CLI -J option takes precedence over SSH config ProxyJump
  • Connections through SSH config ProxyJump work for command execution
  • Connections through SSH config ProxyJump work for file transfers (upload/download)
  • Add test cases for ProxyJump resolution priority

Affected Files

  • src/ssh/ssh_config/mod.rs - get_proxy_jump() exists but unused
  • src/ssh/ssh_config/resolver.rs - resolver function exists
  • src/app/initialization.rs - needs to integrate ProxyJump resolution
  • src/app/dispatcher.rs - needs to pass resolved jump host

Related Issues

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions