Skip to content

agentHost: honor SSH ProxyJump when connecting - #334849

Open
kondv wants to merge 1 commit into
microsoft:mainfrom
kondv:dev/kondv/agent-host-ssh-proxy-config
Open

agentHost: honor SSH ProxyJump when connecting#334849
kondv wants to merge 1 commit into
microsoft:mainfrom
kondv:dev/kondv/agent-host-ssh-proxy-config

Conversation

@kondv

@kondv kondv commented Sep 7, 2026

Copy link
Copy Markdown

Fixes #317445

Problem

Agent Host resolves effective OpenSSH configuration with ssh -G, but did not carry ProxyJump into the ssh2 connection. A host reachable only through its configured jump host was therefore dialed directly from the Agents window and failed with ENOTFOUND or EHOSTUNREACH, while native OpenSSH and Remote SSH succeeded against the same config.

Change

Preserve the resolved ProxyJump value through initial and reconnect configuration. For a single jump host, start native OpenSSH with BatchMode=yes and -W, pass its standard streams to ssh2 through ConnectConfig.sock, and stop the owned helper when the SSH connection closes. The destination is passed after -- so a config-derived value can never be read as an ssh option.

The jump alias, not a pre-resolved hostname, is handed to OpenSSH, so the jump host's own HostName, User, Port and IdentityFile still apply. Final-host authentication, host-key verification, Agent Host bootstrap and WebSocket handling are untouched.

Single-hop only. Comma-separated chains, ProxyCommand, interactive jump-host authentication, askpass IPC and HostKeyAlias behavior are unchanged, and there are no dependency, build or pipeline changes.

Validation

  • npm run compile-client, typecheck-client, valid-layers-check, full eslint, and hygiene on the changed files — all clean
  • Focused vs/platform/agentHost/test/{common,node} suite — 5245 passing. Unpatched main control runs the same suite at 5237 passing with the same two pre-existing CopilotAgent failures, so those are unrelated to this change.
  • Live built Code OSS A/B, captured on commit dca870d (base 7b763e653ee2), using disposable profiles, real key-authenticated jump and target SSH servers, and the actual Agent Host WebSocket relay:
    • Native OpenSSH reached proxyjump-target.invalid:2222 through the configured jump host.
    • Unpatched main used the same Agents UI action, dialed the target directly, failed with getaddrinfo ENOTFOUND, and never contacted the jump or target servers.
    • Patched Code OSS contacted the jump, forwarded to the target, authenticated, launched the real Agent Host, and completed the SSH-forwarded WebSocket connection.
    • A direct-host control completed the same Agent Host flow without starting a jump helper.
    • All owned helper and Agent Host processes exited after the UI closed.
  • The -- terminator was added after that run, so this revision is not byte-identical to the Electron-tested one and the Electron harness was not re-run. It is covered separately: against OpenSSH 9.5p2, ssh -o BatchMode=yes -W target.invalid:22 -V prints the version and exits 0, while the same command with -- -V treats it as a hostname and exits 255; ordinary host and user@host destinations are unaffected. A unit regression asserts -- is always immediately before the destination, and it fails without the production change.

Copilot AI balanced review requested due to automatic review settings September 7, 2026 05:17

Copilot AI 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.

🟡 Changes recommended

Host-key alias handling, IPC and artifact cleanup, and localization issues remain unresolved.

Once you've addressed the issues Copilot identified, you can request another Copilot review.

Pull request overview

Adds SSH proxy support to Agent Host connections, including native askpass prompting and secure proxy lifecycle handling.

Changes:

  • Supports ProxyJump, ProxyCommand, ProxyUseFdpass, and HostKeyAlias.
  • Adds native proxy transports and renderer-mediated authentication prompts.
  • Adds parsing, security, cleanup, and reconnection tests.
File summaries
File Description
src/vs/sessions/contrib/providers/remoteAgentHost/browser/remoteAgentHostActions.ts Forwards resolved proxy configuration.
src/vs/platform/agentHost/test/node/sshRemoteAgentHostService.test.ts Tests proxy transport, askpass, cleanup, and reconnection.
src/vs/platform/agentHost/test/electron-browser/sshRemoteAgentHostService.test.ts Tests renderer prompt handling.
src/vs/platform/agentHost/test/common/sshConfigParsing.test.ts Tests proxy configuration parsing.
src/vs/platform/agentHost/node/sshRemoteAgentHostService.ts Implements proxy transports and askpass IPC.
src/vs/platform/agentHost/electron-browser/sshRemoteAgentHostServiceImpl.ts Presents proxy authentication prompts.
src/vs/platform/agentHost/common/sshRemoteAgentHost.ts Extends SSH configuration and IPC contracts.
src/vs/platform/agentHost/common/sshConfigParsing.ts Parses effective proxy configuration.
Review details

Suppressed comments (1)

src/vs/platform/agentHost/node/sshRemoteAgentHostService.ts:1874

  • This newly surfaced failure message is also not localized. Use a localized template with placeholders for proxyKind and detail, consistent with the other user-facing proxy errors in this method.
				socket.destroy(new Error(`${proxyKind} process exited before the SSH connection was established (${detail}).`));
  • Files reviewed: 8/8 changed files
  • Comments generated: 4
  • Review effort level: Balanced

💡 Configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread src/vs/platform/agentHost/node/sshRemoteAgentHostService.ts Outdated
Comment thread src/vs/platform/agentHost/node/sshRemoteAgentHostService.ts Outdated
Comment thread src/vs/platform/agentHost/node/sshRemoteAgentHostService.ts Outdated
Comment thread src/vs/platform/agentHost/node/sshRemoteAgentHostService.ts Outdated
@vs-code-engineering

Copy link
Copy Markdown
Contributor

📬 CODENOTIFY

The following users are being notified based on files changed in this PR:

Ladislau Szomoru (@lszomoru)

Matched files:

  • build/azure-pipelines/common/checkNativeOptionalDeps.ts

@kondv
kondv force-pushed the dev/kondv/agent-host-ssh-proxy-config branch 2 times, most recently from 8de3d6f to dca870d Compare September 8, 2026 01:22
@kondv kondv changed the title agentHost: Support SSH proxy configuration agentHost: Support SSH ProxyJump Sep 8, 2026
@kondv
kondv force-pushed the dev/kondv/agent-host-ssh-proxy-config branch from dca870d to 16e5021 Compare September 8, 2026 18:11
@kondv kondv changed the title agentHost: Support SSH ProxyJump agentHost: honor SSH ProxyJump when connecting Sep 8, 2026
@kondv

kondv commented Sep 8, 2026

Copy link
Copy Markdown
Author

@microsoft-github-policy-service agree company="Microsoft"

@kondv
kondv force-pushed the dev/kondv/agent-host-ssh-proxy-config branch from 16e5021 to 610da08 Compare September 8, 2026 18:50
@kondv
kondv force-pushed the dev/kondv/agent-host-ssh-proxy-config branch from 610da08 to 0a67175 Compare September 8, 2026 19:35
@kondv

kondv commented Sep 8, 2026

Copy link
Copy Markdown
Author

CI is green except macOS / Electron, which failed on Agent Host E2E — Copilot > cancelling a turn paused for input allows a replacement turn with Execution failed: 500 Internal Server Error from the model backend.

Three runs of this identical tree failed five different tests across three platforms, none of them in code this PR touches. The new path is gated on config.proxyJump, and nothing outside this PR's own tests sets it.

Locally the agentHost node suite is clean on both sides — four runs on main and four here, no failures either way — and the tests that timed out in CI are slightly faster with the patch than without it, for example rejects and cleans an artifact with too many files at 1117 ms patched versus 1236 ms on main, against a 2000 ms budget.

— kondv's Copilot 🤖

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.

Agents view fails to connect to SSH hosts using ProxyJump, while main editor's SSH works

3 participants