Skip to content

run ssh -G for typed hosts so system ProxyCommand still applies - #3136

Open
thedhruvhegde wants to merge 1 commit into
generalaction:mainfrom
thedhruvhegde:fix/ssh-system-config-proxy
Open

run ssh -G for typed hosts so system ProxyCommand still applies#3136
thedhruvhegde wants to merge 1 commit into
generalaction:mainfrom
thedhruvhegde:fix/ssh-system-config-proxy

Conversation

@thedhruvhegde

@thedhruvhegde thedhruvhegde commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

summary

typed ssh hostnames without an sshConfigAlias were skipping ssh -G, so wildcard / system ProxyCommand never applied and the client tried to resolve the hostname locally (ENOTFOUND).

this still uses the stored host/port/user instead of rewriting them from config. ssh -G is only used for proxy settings.

closes #2729

test plan

  • add a connection with a typed hostname that only matches a Host * / wildcard ProxyCommand in ~/.ssh/config and connect
  • connect with an sshConfigAlias still uses that alias for -G
  • pnpm --dir apps/emdash-desktop exec vitest run src/core/services/ssh/node/connect/resolve-ssh-connect-config.test.ts

@greptile-apps

greptile-apps Bot commented Sep 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR resolves effective SSH configuration for typed, non-alias hosts so wildcard and system proxy directives can participate in connection setup while preserving stored endpoint fields.

  • Applies resolved ProxyCommand and ProxyJump settings to typed hosts.
  • Adds coverage for a typed hostname matched by a system ProxyCommand.
  • Introduces a precedence regression when an explicit stored ProxyJump conflicts with a system ProxyCommand.
  • Performs duplicate ssh -G subprocesses for typed hosts using agent authentication.

Confidence Score: 4/5

The PR is not safe to merge until explicit stored ProxyJump connections are protected from being silently overridden by wildcard or system ProxyCommand configuration.

The new typed-host lookup fixes the reported proxy discovery path, but it changes routing precedence for existing manually configured jump-host connections; duplicate sequential ssh -G execution is an additional non-blocking connection-latency concern.

Files Needing Attention: apps/emdash-desktop/src/core/services/ssh/node/connect/resolve-ssh-connect-config.ts, apps/emdash-desktop/src/core/services/ssh/node/connect/resolve-ssh-connect-config.test.ts

Important Files Changed

Filename Overview
apps/emdash-desktop/src/core/services/ssh/node/connect/resolve-ssh-connect-config.ts Extends SSH-config resolution to typed hosts, but lets system ProxyCommand override an explicit stored ProxyJump and duplicates resolution for agent authentication.
apps/emdash-desktop/src/core/services/ssh/node/connect/resolve-ssh-connect-config.test.ts Adds typed-host ProxyCommand coverage and updates agent-resolution expectations, but omits the stored-ProxyJump precedence case.

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[Connection input] --> B{SSH config alias?}
  B -->|Yes| C[Run ssh -G for alias]
  B -->|No| D[Run ssh -G for typed host]
  C --> E[Use resolved endpoint and proxy settings]
  D --> F[Keep stored endpoint fields]
  D --> G[Read resolved proxy settings]
  F --> H[Build proxy tokens]
  G --> I{Resolved ProxyCommand?}
  I -->|Yes| J[Spawn ProxyCommand]
  I -->|No| K{Resolved or stored ProxyJump?}
  K -->|Yes| L[Spawn ProxyJump]
  K -->|No| M[Connect directly]
Loading
Prompt To Fix All With AI
### Issue 1
apps/emdash-desktop/src/core/services/ssh/node/connect/resolve-ssh-connect-config.ts:121
**Stored ProxyJump Is Overridden**

For a typed connection with an explicitly stored `proxyJump`, a wildcard or system `ProxyCommand` returned by the new `ssh -G` lookup now wins because transport selection checks `proxyCommand` first. The connection is routed through the system command instead of the machine-specific jump host. Preserve the explicit connection setting鈥檚 precedence or define and test the intended override behavior.

### Issue 2
apps/emdash-desktop/src/core/services/ssh/node/connect/resolve-ssh-connect-config.ts:88
**SSH Config Resolves Twice**

Agent-authenticated typed hosts now run the same `ssh -G <host>` lookup twice in sequence: once here for proxy settings and again through `resolveManualAgentSshConfig` for authentication. Each subprocess has a ten-second timeout, so a slow or failing resolver can add another full timeout to connection setup. Reuse the first result in the authentication path instead of resolving the same host again.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

Reviews (1): Last reviewed commit: "run ssh -G for typed hosts so system Pro..." | Re-trigger Greptile

let cleanup = () => {};
const tokens: ProxyTokens = { host, port, username, originalHost: alias ?? base.host };
const proxyCommand = alias ? resolved?.proxyCommand : undefined;
const proxyCommand = resolved?.proxyCommand;

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.

P1 Stored ProxyJump Is Overridden

For a typed connection with an explicitly stored proxyJump, a wildcard or system ProxyCommand returned by the new ssh -G lookup now wins because transport selection checks proxyCommand first. The connection is routed through the system command instead of the machine-specific jump host. Preserve the explicit connection setting鈥檚 precedence or define and test the intended override behavior.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/emdash-desktop/src/core/services/ssh/node/connect/resolve-ssh-connect-config.ts
Line: 121

Comment:
**Stored ProxyJump Is Overridden**

For a typed connection with an explicitly stored `proxyJump`, a wildcard or system `ProxyCommand` returned by the new `ssh -G` lookup now wins because transport selection checks `proxyCommand` first. The connection is routed through the system command instead of the machine-specific jump host. Preserve the explicit connection setting鈥檚 precedence or define and test the intended override behavior.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

const resolved = alias ? await deps.resolveSshConfig(alias) : undefined;
const resolved = alias
? await deps.resolveSshConfig(alias)
: await deps.resolveSshConfig(base.host).catch(() => undefined);

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.

P2 SSH Config Resolves Twice

Agent-authenticated typed hosts now run the same ssh -G <host> lookup twice in sequence: once here for proxy settings and again through resolveManualAgentSshConfig for authentication. Each subprocess has a ten-second timeout, so a slow or failing resolver can add another full timeout to connection setup. Reuse the first result in the authentication path instead of resolving the same host again.

Prompt To Fix With AI
This is a comment left during a code review.
Path: apps/emdash-desktop/src/core/services/ssh/node/connect/resolve-ssh-connect-config.ts
Line: 88

Comment:
**SSH Config Resolves Twice**

Agent-authenticated typed hosts now run the same `ssh -G <host>` lookup twice in sequence: once here for proxy settings and again through `resolveManualAgentSshConfig` for authentication. Each subprocess has a ten-second timeout, so a slow or failing resolver can add another full timeout to connection setup. Reuse the first result in the authentication path instead of resolving the same host again.

---

For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.

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.

SSH connection fails for work hosts resolved through system SSH config

1 participant