Skip to content

[v0.2] Use saved profiles as jump hosts - #28

Merged
Lingbou merged 1 commit into
mainfrom
feat/profile-jump-hosts
Sep 30, 2026
Merged

Lingbou merged 1 commit into
mainfrom
feat/profile-jump-hosts

Conversation

@Lingbou

@Lingbou Lingbou commented Sep 30, 2026

Copy link
Copy Markdown
Owner

Parent: #1

Closes #12

What changed

  • JumpHop is now a two-form enum: Endpoint(EndpointHop) (user/host/port) and Profile(ProfileHop) (a profile id). It is #[serde(untagged)], so existing saved chains deserialize unchanged — there is a test locking that in.
  • References are by id, not name, so renaming a connection does not break a chain that points at it.
  • SshRunner::resolve_jump_chain resolves references before OpenSSH starts:
    • the referenced profile contributes its endpoint (host, port, username) and its key, so the hop authenticates as the connection it names;
    • endpoint hops keep the target profile's identity, which is the pasted ssh -J behaviour and unchanged from [v0.2] Support multi-hop ProxyJump chains #11;
    • the referenced profile's own jump chain is deliberately not expanded, which is what makes cycles impossible.
  • Three refusal paths fail before any ssh process runs, each naming the problem:
    • stale reference → this connection uses saved connection <id> as a jump host, but that connection no longer exists; edit the chain to repair it;
    • self-reference → a jump host cannot reference the connection it belongs to;
    • password-backed reference → saved connection "<name>" is used as a jump host but stores a password; jump hosts must authenticate with a key.
  • Failure attribution understands both forms: a failed chain now reports jump i/n <authority> unreachable for endpoint hops and jump i/n <name> (saved connection) unreachable for profile hops.
  • ADR-0002 records the resolution rules and the key-only constraint.

Why passwords are refused for jump hops

Every hop in a chain is a separate ssh process spawned by the previous one. Line hands a saved password to its own askpass child through the environment of the connection it launches, and that environment is shared by the whole nested process tree — there is no per-hop channel today. Silently borrowing the target's password for a hop would be worse than refusing, so the refusal is explicit and the constraint is documented. Per-hop askpass is a separate design if it is ever wanted.

Verification

  • cargo test --all-targets --locked (112 lib tests plus every integration suite, including the two-hop containerized chain), cargo clippy --all-targets --all-features --locked -- -D warnings, cargo +1.88.0 check --all-targets --locked, cargo fmt --check.
  • New unit coverage: legacy endpoint JSON still loads, profile references round-trip, empty reference rejected, endpoint validation unchanged, profile hop uses the referenced endpoint and key (and not the target's key), stale reference, password-backed reference, self-reference, and the saved-connection hop label in failure messages.

A jump hop can now reference another saved profile instead of spelling
out an endpoint. The reference is resolved when connecting: it brings
its own endpoint and key, is not expanded recursively, and fails with a
named error when it is stale, self-referential, or password-backed.

Refs #12

Signed-off-by: Xingqiu Xu <hilbertanjou83@gmail.com>
@Lingbou
Lingbou merged commit 3bc1aaa into main Sep 30, 2026
11 checks passed
@Lingbou
Lingbou deleted the feat/profile-jump-hosts branch September 30, 2026 14:15
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] Use saved profiles as jump hosts

1 participant