Skip to content

[v0.2] Support multi-hop ProxyJump chains - #24

Merged
Lingbou merged 1 commit into
mainfrom
feat/multi-hop-proxyjump
Sep 30, 2026
Merged

Lingbou merged 1 commit into
mainfrom
feat/multi-hop-proxyjump

Conversation

@Lingbou

@Lingbou Lingbou commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Parent: #1

Closes #11

What changed

  • parse_jump_chain splits a pasted ssh -J hop1,hop2 target into ordered hops and rejects malformed chains (a,,b, a,, ,a) with "Jump chain contains an empty hop" instead of bleeding into a hop parser error.

  • The runner builds one nested ProxyCommand per hop. The first hop is connected directly; each later hop carries the previous command as its own ProxyCommand, and the outermost command forwards to the target:

    ssh -o ProxyCommand="ssh ... -W %h:%p -- first-hop" -W %h:%p -- second-hop
    

    OpenSSH expands %h:%p against the destination of the process whose configuration carries the ProxyCommand, so each level forwards to the correct address and Line never has to resolve intermediate addresses itself.

  • When a chain fails, SessionResult::failing_jump_hop reads the OpenSSH diagnostics for whole host tokens and names the hop as jump i/n <authority> unreachable. Matching is token-bounded, so 10.0.0.5 does not match a diagnostic about 10.0.0.55.

  • The obsolete SshError::UnsupportedJumpChain variant is gone.

  • ADR-0002 records the nesting rule and the failure-reporting rule.

Verification

  • docker-backed integration test now runs a real two-hop chain: the first jump is published on the host, the second jump and the target are reachable only through the hop before them, and all three are separate sshd containers on one Docker network.
  • New unit coverage: chain parsing and order, malformed chain rejection, nested-command shape (two ProxyCommand=, two -W, first hop nested inside the second), hop identification with a prefix-overlap case, and editing a profile that already has multiple hops.
  • cargo test --all-targets --locked, cargo clippy --all-targets --all-features --locked -- -D warnings, cargo +1.88.0 check --all-targets --locked, cargo fmt --check all pass.

Note on quoting

Nested commands are embedded with a dedicated shell_quote_nested so the inner command is quoted exactly once for the shell that runs the outer ProxyCommand. Re-quoting it through the general shell_quote produced correct but heavily escaped commands (''''…'''') that made ps output and diagnostics unreadable.

Parse comma-separated -J lists into ordered jump chains, nest one
ProxyCommand per hop, and name the hop OpenSSH blames when a chain
fails. The integration fixture now runs both a single-hop and a two-hop
chain against containerized sshd instances.

Refs #11

Signed-off-by: Xingqiu Xu <hilbertanjou83@gmail.com>
@Lingbou
Lingbou merged commit 406e63c into main Sep 30, 2026
21 of 22 checks passed
@Lingbou
Lingbou deleted the feat/multi-hop-proxyjump branch September 30, 2026 12:12
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.

[v0.2] Support multi-hop ProxyJump chains

1 participant