Skip to content

fix(ssh): a system-SSH host whose sshd refuses forwarding reaches its managed server over exec - #28408

Merged
OrcaWin merged 5 commits into
mainfrom
np/sysssh-exec-bridge
Oct 14, 2026
Merged

OrcaWin merged 5 commits into
mainfrom
np/sysssh-exec-bridge

Conversation

@OrcaWin

@OrcaWin OrcaWin commented Oct 13, 2026 •

Copy link
Copy Markdown
Collaborator
Files Added Deleted Net
Test 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​230 $\color{#cf222e}{\Huge{\mathbf{−}}}$​14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​216
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​180 $\color{#cf222e}{\Huge{\mathbf{−}}}$​14 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​166

ELI5

Some SSH servers allow running commands but refuse to forward network ports. When Orca reached such a server through the system ssh program (for example a jump host, a ProxyCommand, or a hardware security key), it reported the host as connected even though nothing could get through to the managed Orca server. With this change Orca notices the refusal and sends the traffic through a running command instead, which those servers do allow. If even that is impossible, the connect fails with the reason.

What Changed

Before: a host on system OpenSSH with AllowTcpForwarding no started an ssh -N -L forward. Its local listener came up, so the tunnel counted as started. But sshd had not yet been asked to open a channel, and it refused every one. The host showed connected, while workspace calls and terminals could never reach the server. The stdio bridge that handles this case for the built-in SSH client explicitly excluded system SSH, and the forwarding probe returns "unverifiable" without a built-in client.

After:

  • Once a system-SSH forward starts, the managed tunnel dials through it once and reads OpenSSH's own answer for that channel. OpenSSH logs a failed channel open to stderr as open failed: administratively prohibited, or as open failed: connect failed when the remote port has nothing listening. Reply bytes from the server also count: a few junk bytes make orcad's HTTP server answer 400 straight away.
    • Refused: the forward is closed. The tunnel is then carried by the existing stdio bridge, run as a system-SSH exec (ssh <host> <bridge command>), on the same persisted local port.
    • Allowed, or no answer: the forward is kept, exactly as before.
  • If the host refuses forwarding and the bridge cannot run there (no pinned Node), the connect now fails with that reason. It no longer leaves a dead forward that looks healthy.
  • A refusal is remembered for that SSH transport generation, so a tunnel restart goes straight to the bridge. Before binding, it frees the persisted port, which an orphaned ssh -L may hold.
  • System-SSH forwards now pass -o LogLevel=INFO. OpenSSH logs a refused channel at INFO, so a user config with LogLevel ERROR or QUIET would otherwise hide the refusal. The orphaned-forward matcher from fix(ssh): an SSH host comes back after restarting Orca instead of staying offline (STA-10476) #28398 ignores that one option, so a stuck forward left by an older version is still recognised and cleared after the update.
  • A forward whose ssh exits during the check now fails the start. Before, it was handed back as live while the manager could not yet hear its exit.
  • The check also retries the local dial while ssh is still binding. The startup wait can end on its 750 ms grace timer before the listener exists, for example behind a jump host.

Why

  • Why carry the bridge over exec rather than only fail loudly: exec is how every orcad host operation already runs on these hosts, so this is the one route that works when forwarding is refused. The bridge's framing, listener and session cap are reused unchanged.
  • Why not make the exec bridge the default for every system-SSH host: each bridged stream is a separate sshd session plus a Node process on the host. Over Orca's ControlMaster, those sessions share one connection's MaxSessions (10 by default) with all other exec work. With multiplexing off, each one is a fresh login, which means a security-key touch every time. That is a larger behaviour change than this release should carry. -L stays the default wherever it works.
  • Why read ssh's stderr: a system-SSH forward runs in its own process, and that log line is the only place sshd's answer to a channel open becomes visible. It is the same RFC 4254 reason code the built-in client's probe already reads.

Linked Issue

Fixes #24863

Visual Proof

N/A: no UI change. The difference is that the connection works (or fails with a reason) instead of showing connected.

Testing

  • I manually tested these changes locally
  • Automated tests added/updated, or explained why not below

Real host (Linux, OpenSSH 10.5): I ran a user-level sshd with AllowTcpForwarding no on a high port and reached it from macOS through -J (ProxyJump, so system SSH):

  • The channel check on the real ssh -L read refused in 10 ms.
  • On a host that allows forwarding, the same check read allowed from reply bytes in 52 ms.
  • The full OrcadManagedTunnelTransportProvider.start closed the -L and served the persisted local port over the system-SSH exec bridge. HTTP went end to end, and the transport was recorded as stdio_bridge.
  • The scratch sshd was removed afterwards.

Unit tests:

  • The transport replaces a refused system-SSH forward with the bridge, closing the forward first.
  • It fails loudly when there is no bridge route.
  • It keeps the forward when the answer is allowed or unverifiable.
  • It skips straight to the bridge on the same generation, and re-checks after a reconnect.
  • The channel check covers each of OpenSSH's answers, a refusal logged after the drop, reply bytes, and the unverifiable cases.
  • The bridge provider accepts system SSH.

pnpm tc, pnpm lint, oxlint and check:code-quality:changed all pass.

No new Docker e2e case. The Docker fixture has no system-SSH route: system OpenSSH reads host keys from the account's real ~/.ssh, which the e2e HOME isolation does not cover. The existing "sshd refuses TCP forwarding" Docker spec still covers the built-in client's bridge path.

Review

Agent skill upstream boundary

  • Not applicable, or this change copies or mechanically translates no upstream skill-installer source, tests, fixtures, registry entries, path tables, comments, or documentation.

Notes

Checklist

  • This PR is small and focused
  • I explained what changed and why (ELI5, the user-facing before/after, the mechanism, and why over the alternatives)
  • Before/after screenshots or videos attached for UI changes, or N/A with reason
  • Self-reviewed for correctness, security, and performance
  • Cross-platform, SSH/remote, and path/shortcut impact considered (or N/A)
  • pnpm lint, pnpm typecheck, pnpm test, and pnpm build pass (or CI will cover; local preferred)

@coderabbitai

coderabbitai Bot commented Oct 13, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: b9e14bd4-278f-43d7-92c3-910515f68cbd
📥 Commits

Reviewing files that changed from the base of the PR and between e56f4ab and bf81ee5.

📒 Files selected for processing: 2
  • src/main/ssh/orcad-managed-tunnel-transport.test.ts
  • src/main/ssh/orcad-managed-tunnel-transport.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

📝 Walkthrough

The SSH transport provider checks whether a started forward can open a channel. It closes a forward and selects the stdio bridge when the channel is refused. It records that refusal for the current connection generation and reserves a requested nonzero local port before later bridge starts in that generation. System SSH connections can use the bridge. New tests cover forwarding verdicts, transport selection, and reconnect behavior.

Priority: ➖ Normal

Merge Risk: ⚪ Minimal · up to bf81e

Hosts reached through system SSH whose sshd refuses forwarding now fall back to the exec bridge, and the earlier concerns about port conflicts and stale refusals appear fixed. No concrete merge-blocking risk remains.

Pre-merge checks: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning Docstring coverage is 40.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 10 functions across 14 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed Passed checks: 4 passed
Check name Status Explanation
Description check Passed The description follows the repository template and covers the user impact, implementation, rationale, linked issue, testing, platform considerations, and checklist. It is complete and specific.
Title check Passed The title is concise, specific, and accurately identifies the primary change: system-SSH hosts that refuse forwarding use the managed server through exec.
Linked Issues check Passed Issue #24863 is closed and supplies historical context only. It has no active coding requirements for this pull request. The pull request adds system-SSH forwarding checks, bridge fallback, failure ha…
Out of Scope Changes check Passed The changes stay within managed-tunnel transport selection for system OpenSSH. The production changes implement channel checks, refusal handling, stdio-bridge fallback, generation handling, logging, a…
  • Fix all pre-merge checks with AI
✨ Finishing Touches: 💡 1
📝 Generate docstrings: 💡
  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: a4c4f54d-666f-4e8c-b49c-b466623ff536
📥 Commits

Reviewing files that changed from the base of the PR and between 6cfe678 and 2c95c6d549edfe5f0dd408e33324e4910a3dbbbe.

📒 Files selected for processing: 8
  • src/main/ssh/orcad-managed-tunnel-transport.test.ts
  • src/main/ssh/orcad-managed-tunnel-transport.ts
  • src/main/ssh/orcad-stdio-bridge-provider.test.ts
  • src/main/ssh/orcad-stdio-bridge-provider.ts
  • src/main/ssh/ssh-port-forward-provider.ts
  • src/main/ssh/ssh-tcp-forwarding-probe.test.ts
  • src/main/ssh/ssh-tcp-forwarding-probe.ts
  • src/main/ssh/system-ssh-port-forward-provider.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 5 remain after this review.

@OrcaWin
OrcaWin force-pushed the np/sysssh-exec-bridge branch from 2c95c6d to f11e65c Compare October 13, 2026 20:47

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: fa168bfa-3a41-45c4-a8d4-02a484b09196
📥 Commits

Reviewing files that changed from the base of the PR and between 2c95c6d549edfe5f0dd408e33324e4910a3dbbbe and f11e65c.

📒 Files selected for processing: 6
  • src/main/ssh/orcad-managed-tunnel-transport.test.ts
  • src/main/ssh/orcad-managed-tunnel-transport.ts
  • src/main/ssh/ssh-port-forward.test.ts
  • src/main/ssh/ssh-system-fallback.test.ts
  • src/main/ssh/system-ssh-args.ts
  • src/main/ssh/system-ssh-port-forward-provider.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 4 remain after this review.

@OrcaWin
OrcaWin force-pushed the np/sysssh-exec-bridge branch 2 times, most recently from b5fa9d8 to e56f4ab Compare October 13, 2026 23:25

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration
  • Configuration used: Repository UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 9129cb99-2962-46e7-9e30-7c92a0e98b13
📥 Commits

Reviewing files that changed from the base of the PR and between b5fa9d8 and e56f4ab.

📒 Files selected for processing: 2
  • src/main/ssh/orcad-managed-tunnel-transport.test.ts
  • src/main/ssh/orcad-managed-tunnel-transport.ts

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 9 remain after this review.

m4air added 5 commits October 13, 2026 17:48
… managed server over exec

A host Orca reaches through system OpenSSH (ProxyJump/ProxyCommand, security
keys) and whose sshd runs AllowTcpForwarding no showed connected while no
managed-server traffic could pass: the ssh -L listener comes up before sshd is
ever asked for a channel, and the stdio bridge excluded system SSH.

The managed tunnel now dials once through a fresh system-SSH forward and reads
OpenSSH's own channel answer from its stderr. An administrative refusal closes
the forward and carries the tunnel over the stdio bridge on a system-SSH exec,
on the same persisted local port; a host where the bridge cannot run fails the
connect with that reason instead of reporting a dead forward as up.

Refs #24863
@OrcaWin
OrcaWin force-pushed the np/sysssh-exec-bridge branch from e56f4ab to bf81ee5 Compare October 14, 2026 00:48
@OrcaWin
OrcaWin merged commit e4824ce into main Oct 14, 2026
57 checks passed
registered2nd pushed a commit to registered2nd/orca that referenced this pull request Oct 14, 2026
… managed server over exec (stablyai#28408)

* fix(ssh): a system-SSH host whose sshd refuses forwarding reaches its managed server over exec

A host Orca reaches through system OpenSSH (ProxyJump/ProxyCommand, security
keys) and whose sshd runs AllowTcpForwarding no showed connected while no
managed-server traffic could pass: the ssh -L listener comes up before sshd is
ever asked for a channel, and the stdio bridge excluded system SSH.

The managed tunnel now dials once through a fresh system-SSH forward and reads
OpenSSH's own channel answer from its stderr. An administrative refusal closes
the forward and carries the tunnel over the stdio bridge on a system-SSH exec,
on the same persisted local port; a host where the bridge cannot run fails the
connect with that reason instead of reporting a dead forward as up.

Refs stablyai#24863

* fix(ssh): keep refusal logs under a quiet LogLevel; fail a forward that exits mid-check

* fix(ssh): an orphaned forward from before LogLevel=INFO still matches for recovery

* fix(ssh): confirm the persisted port is free before the stdio bridge binds it

* fix(ssh): record a forwarding refusal against the transport generation that answered it

---------

Co-authored-by: m4air <[email protected]>
(cherry picked from commit e4824ce)
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.

1 participant