Repository navigation
Conversation
…he first identity `ssh -G <alias>` exits 0 for an alias with no Host block and prints a fully populated default config, so a non-null resolution was treated as fresh OpenSSH authority and replaced the stored host/port/user/proxy/identity. Also seed ssh2 with the first parseable identity: Client.connect parses config.privateKey eagerly, so an encrypted first key aborted the connect before the multi-key authHandler could try the rest. Co-authored-by: Orca <[email protected]>
Greptile SummaryThis PR fixes two bugs introduced by #11297 in the ssh2 transport path: (1)
Confidence Score: 5/5Safe to merge; both root causes are correctly addressed and all changed call sites have matching test coverage. The heuristic in hasOpenSshHostBlockMatch is conservative — false negatives keep stored fields, false positives apply fresh config. The selectEagerPrivateKey fallback to keys[0] preserves the passphrase prompt for encrypted-only lists. The test plan explicitly verified each fixed failure against unfixed source. Known limitations around wildcard-proxy false positives and the system-SSH transport half are documented and tracked in #11746. Files Needing Attention: No files require special attention.
|
| Filename | Overview |
|---|---|
| src/main/ssh/ssh-g-host-block-match.ts | New predicate detecting genuine Host-block matches; logic is sound with well-documented limitations around wildcards and CanonicalizeHostname. |
| src/main/ssh/ssh-private-key-authentication.ts | selectEagerPrivateKey correctly finds the first parseable key; encrypted-only fallback to keys[0] preserves the passphrase prompt path. |
| src/main/ssh/ssh-auth-resolution.ts | Three isOpenSshConfigBackedTarget guards replaced with hasOpenSshHostBlockMatch; resolvePrivateKeyPaths and resolveIdentityFilePaths remain identical bodies (pre-existing, noted in prior thread). |
| src/main/ssh/ssh-connection-utils.ts | buildConnectConfig, resolveEffectiveHost/Port/Proxy all gated on hasOpenSshHostBlockMatch; stored fields win in no-match branch. |
| src/main/ssh/ssh-connection.ts | GitHub restricted-shell and GSSAPI probes gated correctly; distro-wide GSSAPI pickup preserved via isOpenSshConfigBackedTarget secondary condition. |
| src/main/ssh/ssh-g-host-block-match.test.ts | 10 tests covering all four heuristic signals, manual-target bypass, and local-account-unknown path. |
| src/main/ssh/ssh-connection.test.ts | Three new integration tests covering git-username and GSSAPI flag preservation when alias block is gone. |
| src/main/ssh/ssh-multi-key-authentication.test.ts | Three new cases: encrypted-first skipped, all-encrypted fallback to keys[0], single-encrypted-only. |
Flowchart
%%{init: {'theme': 'neutral'}}%%
flowchart TD
A[hasOpenSshHostBlockMatch called] --> B{isOpenSshConfigBackedTarget\nAND resolved non-null?}
B -->|No| C[return false - stored fields win]
B -->|Yes| D{resolved.hostname empty?}
D -->|Yes| E[return true - trust resolved]
D -->|No| F{hostname != configHost/label?}
F -->|Yes| E
F -->|No| G{port set AND port != 22?}
G -->|Yes| E
G -->|No| H{proxyCommand or proxyJump?}
H -->|Yes| E
H -->|No| I{localAccountName resolvable?}
I -->|No| C
I -->|Yes| J{user non-empty AND != local?}
J -->|Yes| E
J -->|No| C
Reviews (8): Last reviewed commit: "fix(ssh): gate the remaining #11297 conf..." | Re-trigger Greptile
|
Note Reviews pausedIt 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 Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
📝 WalkthroughWalkthroughThe SSH resolution flow now detects applied OpenSSH 🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Caution
Some comments are outside the diff and can’t be posted inline due to platform limitations.
⚠️ Outside diff range comments (2)
src/main/ssh/ssh-auth-resolution.ts (1)
101-109: 📐 Maintainability & Code Quality | 🟠 Major | ⚡ Quick winConsolidate identical
resolvePrivateKeyPathsandresolveIdentityFilePaths.
resolvePrivateKeyPaths(Line 101) andresolveIdentityFilePaths(Line 178) now have identical bodies. This PR had to apply the samehasOpenSshHostBlockMatchchange to both. A future change risks updating one and missing the other.Extract one shared helper and let both functions delegate to it.
♻️ Proposed consolidation
+function resolveIdentityCandidatePaths(target: SshTarget, resolved: SshResolvedConfig | null): string[] { + if (hasOpenSshHostBlockMatch(target, resolved) && resolved) { + return resolved.identityFile + } + if (target.identityFile) { + return [target.identityFile] + } + return resolved?.identityFile ?? [] +} + -function resolvePrivateKeyPaths(target: SshTarget, resolved: SshResolvedConfig | null): string[] { - if (hasOpenSshHostBlockMatch(target, resolved) && resolved) { - return resolved.identityFile - } - if (target.identityFile) { - return [target.identityFile] - } - return resolved?.identityFile ?? [] -} +function resolvePrivateKeyPaths(target: SshTarget, resolved: SshResolvedConfig | null): string[] { + return resolveIdentityCandidatePaths(target, resolved) +} ... -function resolveIdentityFilePaths(target: SshTarget, resolved: SshResolvedConfig | null): string[] { - if (hasOpenSshHostBlockMatch(target, resolved) && resolved) { - return resolved.identityFile - } - if (target.identityFile) { - return [target.identityFile] - } - return resolved?.identityFile ?? [] -} +function resolveIdentityFilePaths(target: SshTarget, resolved: SshResolvedConfig | null): string[] { + return resolveIdentityCandidatePaths(target, resolved) +}Also applies to: 178-186
src/main/ssh/ssh-connection-utils.ts (1)
223-231: 🎯 Functional Correctness | 🟠 Major | ⚡ Quick winGate stale-alias defaults back through
hasOpenSshHostBlockMatch.When
ssh -Greturns defaults withhostname === alias,shouldUseResolvedEndpointstill acceptstarget.host === '',target.configHost, ortarget.label, so it can override a stored target toaliaseven without a matching Host block. Keep the Host-block guard on this branch.
🧹 Nitpick comments (2)
src/main/ssh/ssh-g-host-block-match.ts (1)
6-6: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low valueOptional: export
DEFAULT_SSH_PORTfor reuse.
ssh-connection-utils.tshardcodes the literal22inresolveEffectivePortin two places. Export this constant and import it there. This avoids two independent sources of truth for the default SSH port.src/main/ssh/ssh-g-host-block-match.test.ts (1)
38-170: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick winAdd coverage for the empty-hostname fallback in
hasOpenSshHostBlockMatch.No test exercises the branch in
ssh-g-host-block-match.tswhereresolved.hostnameis empty (Line 48 comment: an empty hostname means the resolution never went throughssh -G, so it's treated as authoritative). Add a case withresolved.hostnameunset to confirm this fallback returns a match.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 9d32d656-75e0-4f36-9d37-962f37350049
📒 Files selected for processing (6)
src/main/ssh/ssh-auth-resolution.tssrc/main/ssh/ssh-connection-utils.tssrc/main/ssh/ssh-g-host-block-match.test.tssrc/main/ssh/ssh-g-host-block-match.tssrc/main/ssh/ssh-multi-key-authentication.test.tssrc/main/ssh/ssh-private-key-authentication.ts
…lockMatch The port case fixture stored port 22, so resolveEffectivePort's pre-existing `configHost && port === 22` branch returned the resolved port whether or not the predicate's port rule existed; the proxy rule had no test at all. Both rules can now be deleted only at the cost of a failing test, as can the HostName rule. Co-authored-by: Orca <[email protected]>
…ock evidence Why: `ssh -G <vanished-alias>` still exits 0 with defaults, so the GitHub restricted-shell probe read the local account instead of a stored `git` username, and a defaulted `gssapiauthentication no` discarded a stored Kerberos flag. A resolved `yes` still wins so distro-wide defaults keep working. Also treats an undeterminable local account as no evidence, and matches ssh2's first-entry rule for the eager private key.
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: 89a9bbea-8a5b-4f19-82ae-2005f70b405b
📒 Files selected for processing (6)
src/main/ssh/ssh-connection.test.tssrc/main/ssh/ssh-connection.tssrc/main/ssh/ssh-g-host-block-match.test.tssrc/main/ssh/ssh-g-host-block-match.tssrc/main/ssh/ssh-multi-key-authentication.test.tssrc/main/ssh/ssh-private-key-authentication.ts
🚧 Files skipped from review as they are similar to previous changes (4)
- src/main/ssh/ssh-g-host-block-match.test.ts
- src/main/ssh/ssh-multi-key-authentication.test.ts
- src/main/ssh/ssh-private-key-authentication.ts
- src/main/ssh/ssh-g-host-block-match.ts
Item 1 (P1) — fixed:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
src/main/ssh/ssh-g-config-resolution.ts (1)
36-64: 🧹 Nitpick | 🔵 TrivialConsider caching the baseline probe across reconnect attempts.
resolveWithSshGspawns twossh -Gprocesses per call.attemptConnectandconnectViaSystemSshinvoke this on every connection attempt, including automatic reconnects. For hosts with frequent disconnects (flaky networks, GSSAPI retries), this doubles subprocess overhead on each attempt. The baseline probe result depends only on global/wildcard SSH configuration, not on the target alias, so a short-lived cache of the baseline signature (invalidated onssh_configmtime change, or scoped to a single reconnect loop) could reduce redundant spawns without affecting correctness.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Pro Plus
Run ID: febf25d7-8e73-4882-b64b-33955b0d597c
📒 Files selected for processing (5)
src/main/ssh/ssh-connection.test.tssrc/main/ssh/ssh-connection.tssrc/main/ssh/ssh-g-config-resolution.tssrc/main/ssh/ssh-g-host-block-match.test.tssrc/main/ssh/ssh-g-host-block-match.ts
🚧 Files skipped from review as they are similar to previous changes (2)
- src/main/ssh/ssh-g-host-block-match.ts
- src/main/ssh/ssh-connection.test.ts
| // Why: `ssh -G` ran against `configHost || label` while system SSH dials | ||
| // `configHost || host`, so the resolved hostname only describes the endpoint that | ||
| // answered when configHost is set; otherwise it just resolved a display label. | ||
| const resolvedHost = target.configHost ? resolvedConfig?.hostname?.trim() : undefined |
There was a problem hiding this comment.
🎯 Functional Correctness | 🟠 Major | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
#!/bin/bash
set -euo pipefail
fd 'ssh-connection.test.ts' src/main/ssh --exec rg -n -B3 -A15 "restricted.?shell|isGitHubRestrictedShellProbeSuccess|ORCA-SYSTEM-SSH-OK" {}Repository: stablyai/orca
Length of output: 19538
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== locate files =="
fd 'ssh-connection\.ts|ssh-connection\.test\.ts' src/main/ssh
echo "== outline main =="
ast-grep outline src/main/ssh/ssh-connection.ts --view compact || true
echo "== relevant main lines 1-140 =="
sed -n '1,140p' src/main/ssh/ssh-connection.ts
echo "== relevant tests around GitHub probes =="
sed -n '1150,1340p' src/main/ssh/ssh-connection.test.tsRepository: stablyai/orca
Length of output: 12188
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== find host block match parser code/tests =="
fd 'ssh-g-host-block-match\.ts|ssh-g-host-block-match\.test\.ts|ssh-custom-config-parser.*|ssh-.*custom.*|^.*ssh.*parser.*' src/main/ssh src/main/shared -x sh -c 'echo "--- $1"; sed -n "1,220p" "$1"' sh {}
echo "== search hasOpenSshHostBlockMatch usages =="
rg -n "hasOpenSshHostBlockMatch|resolveWithSshG|resolvedConfig" src/main/ssh src/main/shared -g '*.ts' -g '!*.test.ts'Repository: stablyai/orca
Length of output: 28732
🏁 Script executed:
#!/bin/bash
set -euo pipefail
echo "== search for OpenSSH HostName default behavior in docs/tests =="
rg -n "Hostname|HostName|ssh -G|configHost|hostBlockEvidence|stale|no matching|no Host|Host block" src/main/ssh src/main/shared README.md package.json -g '*.ts' -g '*.md'
echo "== inspect parser-specific host block evidence files =="
git ls-files 'src/main/ssh/*config*.ts' 'src/main/ssh/*host*.ts' 'src/main/ssh/*parser*.ts' | sortRepository: stablyai/orca
Length of output: 50369
Gate resolvedHost on hasOpenSshHostBlockMatch.
When configHost is a stale alias with no matching Host block, ssh -G can return the alias back as hostname. That false resolvedHost replaces [target.host, target.configHost] with [configHost] and can skip checking target.host. Use the same host-block match predicate already used for effectiveUser.
Proposed fix
- const resolvedHost = target.configHost ? resolvedConfig?.hostname?.trim() : undefined
+ const resolvedHost = hasOpenSshHostBlockMatch(target, resolvedConfig)
+ ? resolvedConfig?.hostname?.trim()
+ : undefined
const hostCandidates = resolvedHost ? [resolvedHost] : [target.host, target.configHost]|
Review round addressed in c694fe269a. Summary of what changed, what I refuted, and what I deliberately left. 1. Baseline probe running for targets that can never use it — valid, fixedConfirmed. Tests (all fail on the pre-fix source, verified by reverting the two source files and re-running):
The existing 2. P1 still reproduces on the system-SSH transport — valid, deliberately not fixed; PR scope corrected insteadReproduced exactly as described. With the stated target and resolved config, I took resolution (a). The PR body now opens with an explicit Scope section stating the fix covers the ssh2 transport only, the old out-of-scope bullet that claimed this case "falls through to ssh2, functionally equivalent" is corrected (it is wrong — I did not attempt (b) in this PR: pinning the stored endpoint changes what a wildcard 3. Word-boundary hole in the differential mask — valid, fixedConfirmed and fixed by dropping One correction to the report, in the fix's favour: on OpenSSH 10.2 Neither side was masked pre-fix, so the signatures differed and the verdict came back New tests, on production-shaped Suggestions
VerificationEvery |
|
Thanks — both blocking items verified against the branch. Pushed 1. P1 under wildcards narrower than
|
| config | alias | before | after |
|---|---|---|---|
Host *.internal / User ops |
prod.internal |
true ❌ | false ✅ |
Host *.corp.example.com / User ops + ProxyJump bastion |
prod.corp.example.com |
true ❌ | false ✅ |
Host prod-* / User ops |
prod-web |
true ❌ | false ✅ |
Host i-* mi-* / ProxyCommand aws ssm start-session --target %h |
i-0abc123def |
true ❌ | false ✅ |
Host 10.* / User ops |
10.0.0.5 |
true ❌ | false ✅ |
Host *.internal + unrelated Host other.internal (your db.internal repro) |
db.internal |
true ❌ | false ✅ |
Host prod.internal / HostName|Port|User|IdentityFile|ForwardAgent (5 cases) |
prod.internal |
true | true ✅ |
Match host prod.internal / User deploy |
prod.internal |
true | true ✅ |
Host *.internal + real Host prod.internal block |
prod.internal |
true | true ✅ |
Host * / Host * !nope / %h and %h_… expansions |
— | false | false ✅ |
Host github.com / User git |
github.com |
true | true ✅ |
Host ????.internal / User ops |
prod.internal |
true | true (residual) |
Host *dev / User ops |
webdev |
true | true (residual) |
Two verdicts intentionally changed beyond your list, both toward false (the safe direction — caller falls back to the stored snapshot):
Host pr*/ aliasprod, andHost prod.*/ aliasprod.internal. These are wildcards that don't name the alias, sofalsematches the documented contract ("a block that names this alias"). The parser never imports wildcard patterns (ssh-config-parser.ts:51-52), so a config-backed target can only reach a wildcard-is-my-only-block state after a hand edit; it then keeps the values it was imported with instead of the bare-alias defaults. Called out in the docstring.
Residual list at ssh-g-config-resolution.ts:46-63 rewritten: the inverted ./- rationale is gone, the surviving true residuals are now fixed-width patterns (Host ????.internal) and suffix globs over a separator-free alias (Host *dev / webdev), and the new false residual (a glob wide enough to cover the probe) is listed.
Pinned with 7 stubbed tests in ssh-g-host-block-match.test.ts — 6 parameterised wildcard shapes plus one that a real block underneath a suffix wildcard is still detected. All 6 fail on the pre-fix probe and pass after.
2. Item 2 ships as a no-op — valid, resolved by dropping the branch
Confirmed your trace: normalizeSshTarget (persistence.ts:1187-1189) is applied on every store read/write including getSshTarget (persistence.ts:6354), SshConnectionStore.addTarget/upsertRuntimeOwnedTarget default it, and the only new SshConnection(...) (ssh-connection-manager.ts:45) is fed from sshStore.getTarget(...). target.configHost is therefore always set, the undefined branch was unreachable, and the why-comment described a state that cannot occur.
Chose your first option: reverted resolvedHost to resolvedConfig?.hostname?.trim() (byte-identical production behaviour, minus the dead ternary) and replaced the synthetic manual + no-configHost test with one exercising the state a user can reach — a config-backed alias whose Host block is gone resolves to itself (github-work), so the stored github.com must not vouch for whoever answered, and the restricted-shell probe is rejected. The comment now records that as the reason the fallback stays ungated, i.e. why CodeRabbit's proposed hasOpenSshHostBlockMatch gate is the wrong fix (system-ssh-args.ts:79 dials configHost || host).
I recorded Item 2 as refuted-with-a-coverage-fix rather than silently keeping dead code. Happy to restore the gate as an explicit defensive assert if you'd rather have belt-and-braces there.
Left alone (deliberately)
- Baseline latency /
Promise.all. Not touched. A shorter baseline budget is a real improvement but changes the failure ratio between the differential verdict and the effective-config heuristic on slowMatch exechosts, which is exactly the fallback path this PR is trying to stop relying on. That deserves its own PR with its own tests rather than riding along here. - GSSAPI probe widening and
selectEagerPrivateKey— your analysis matches mine; intentional and already pinned. shouldUseSystemSshTransportstill ungated, with the existingKnown gapdocstring explaining why gating it is not a safe one-liner.
Verification
src/main/ssh: 75 files / 1121 passed, 1 skippedsrc/relay+src/main/persistence+ renderer settings: 233 files / 2394 passedsrc/main/github+src/main/ipc: 203 files / 3168 passed, 1 skippednpx oxlint src/main/ssh,oxfmt --check,npx tsc --noEmit -p config/tsconfig.node.json— clean
No existing assertion was weakened or deleted. The one removed test (accepts GitHub restricted-shell SSH probes when only a display label resolved) was added by this PR two commits ago and asserted a state persistence prevents; it is replaced by a stricter assertion on a reachable state.
9db4d72 to
727f74b
Compare
Remediation backed out — branch reset to
|
Correction: my earlier reset was too aggressiveThe reset I posted earlier reset this branch to its first commit, not its last reviewed-clean one. The original fix round ran 07-30 21:55–23:41; the failed remediation began 07-31 01:18. I used the wrong boundary and dropped 1–2 legitimate commits that were part of the reviewed-clean PR. The branch is now at the correct boundary — the last commit before remediation started. Apologies for the churn; the force-pushes were mine, not a tooling issue. |
A wildcard `Host *` block supplies ProxyCommand/ProxyJump for every alias, so shouldUseSystemSshTransport picks the system transport for an alias whose own Host block was renamed or deleted, and buildSshArgs then dials that alias verbatim: no -l, no -p, no Hostname. Orca connects as the wildcard's user to the wildcard's host and discards the endpoint it stored (#11746). The signal #11746 assumed (hostBlockMatch, from the still-open #11707) does not exist, and `ssh -G` cannot supply it — it prints the merged config and answers for unknown aliases too. The config file is the only source of truth, so: - parseSshConfigAliasClaims retains raw Host patterns and flags Match blocks, which parseSshConfig discards because it mints importable targets. - sshConfigMayClaimAlias is sound in the negative direction only: an unreadable file, any Match block, or any non-catch-all pattern that might match all answer "claimed", so absence of evidence is never read as evidence of absence. Only a proven-unclaimed alias licenses an override. - buildSshArgs then states Hostname/Port/User, and only those: the wildcard is still the route, and -o Hostname does not change block selection, so the proxy keeps applying and %h expands to the host we mean. The verdict is injected rather than read inside buildSshArgs, so an arg builder does not answer differently per machine. Default is today's behaviour. Scoped to the system-SSH transport and the connection's own command/transport path. Port-forward processes and the ssh2 transport (#11707) are unchanged.
…nd say where a clone failed (#17946) * fix(ssh): answer every MFA stage, not just the first ssh2 walks one flat auth-method list exactly once, so keyboard-interactive could only ever be offered a single time. A host running `AuthenticationMethods keyboard-interactive,keyboard-interactive` (or any ladder ending in a second challenge) partial-succeeds the first stage and then finds the list exhausted, which the user sees as "All configured authentication methods failed" — the reports in #8622 and #16820. Orca's own auth handler now runs for every target instead of only multi-key ones, and rebuilds its queue on each SSH_MSG_USERAUTH_FAILURE that carries partial success, narrowed to the methods the host still offers. Narrowing also stops keys being re-offered after the host has moved past publickey, which is what exhausts MaxAuthTries before the challenge is ever shown. Covered by a real ssh2 server fixture that stages partial success. * fix(git): say where a failing clone ran and why nothing could prompt Clones go through nonInteractiveGitEnv, so `ssh` runs with BatchMode=yes and an emptied SSH_ASKPASS. On a remote or paired-runtime clone that produces `fatal: Could not read from remote repository.` while the same `git clone` typed by hand on that box succeeds — the divergence in #14533. Nothing in the message said the clone ran on the other machine, under its keys, with the prompt deliberately disabled. getGitCloneFailureMessage now appends that fact, and names the two recognisable shapes: a publickey refusal (load the key into an agent there) and a host-key failure (record the key in that machine's known_hosts). Unrecognised SSH failures still get the where-it-ran note; non-SSH failures are untouched. One builder, so the SSH-target relay path and the runtime path both get it. * fix(ssh): stop dialling a bare alias no ssh_config block claims A wildcard `Host *` block supplies ProxyCommand/ProxyJump for every alias, so shouldUseSystemSshTransport picks the system transport for an alias whose own Host block was renamed or deleted, and buildSshArgs then dials that alias verbatim: no -l, no -p, no Hostname. Orca connects as the wildcard's user to the wildcard's host and discards the endpoint it stored (#11746). The signal #11746 assumed (hostBlockMatch, from the still-open #11707) does not exist, and `ssh -G` cannot supply it — it prints the merged config and answers for unknown aliases too. The config file is the only source of truth, so: - parseSshConfigAliasClaims retains raw Host patterns and flags Match blocks, which parseSshConfig discards because it mints importable targets. - sshConfigMayClaimAlias is sound in the negative direction only: an unreadable file, any Match block, or any non-catch-all pattern that might match all answer "claimed", so absence of evidence is never read as evidence of absence. Only a proven-unclaimed alias licenses an override. - buildSshArgs then states Hostname/Port/User, and only those: the wildcard is still the route, and -o Hostname does not change block selection, so the proxy keeps applying and %h expands to the host we mean. The verdict is injected rather than read inside buildSshArgs, so an arg builder does not answer differently per machine. Default is today's behaviour. Scoped to the system-SSH transport and the connection's own command/transport path. Port-forward processes and the ssh2 transport (#11707) are unchanged. * fix(ssh): read a negated Host group as uncertainty, and gate clone SSH guidance `Host * !prod` applies to every alias but `prod`, yet skipping both the catch-all and the `!` pattern answered "unclaimed" for `stage` — which licences overriding Hostname/Port/User against a block the user wrote. Any negation now makes the whole group uncertain; the function is only sound in the negative direction. Also require an ssh(1) diagnostic beside "could not read from remote repository" before appending the SSH clone note: git prints that same line for the HTTP remote helper, where advice about keys and agents is simply wrong. * fix(i18n): restore the activity-options key the rebase dropped * fix(i18n): union en.json with main so the rebase cannot drop keys
…nd say where a clone failed (stablyai#17946) * fix(ssh): answer every MFA stage, not just the first ssh2 walks one flat auth-method list exactly once, so keyboard-interactive could only ever be offered a single time. A host running `AuthenticationMethods keyboard-interactive,keyboard-interactive` (or any ladder ending in a second challenge) partial-succeeds the first stage and then finds the list exhausted, which the user sees as "All configured authentication methods failed" — the reports in stablyai#8622 and stablyai#16820. Orca's own auth handler now runs for every target instead of only multi-key ones, and rebuilds its queue on each SSH_MSG_USERAUTH_FAILURE that carries partial success, narrowed to the methods the host still offers. Narrowing also stops keys being re-offered after the host has moved past publickey, which is what exhausts MaxAuthTries before the challenge is ever shown. Covered by a real ssh2 server fixture that stages partial success. * fix(git): say where a failing clone ran and why nothing could prompt Clones go through nonInteractiveGitEnv, so `ssh` runs with BatchMode=yes and an emptied SSH_ASKPASS. On a remote or paired-runtime clone that produces `fatal: Could not read from remote repository.` while the same `git clone` typed by hand on that box succeeds — the divergence in stablyai#14533. Nothing in the message said the clone ran on the other machine, under its keys, with the prompt deliberately disabled. getGitCloneFailureMessage now appends that fact, and names the two recognisable shapes: a publickey refusal (load the key into an agent there) and a host-key failure (record the key in that machine's known_hosts). Unrecognised SSH failures still get the where-it-ran note; non-SSH failures are untouched. One builder, so the SSH-target relay path and the runtime path both get it. * fix(ssh): stop dialling a bare alias no ssh_config block claims A wildcard `Host *` block supplies ProxyCommand/ProxyJump for every alias, so shouldUseSystemSshTransport picks the system transport for an alias whose own Host block was renamed or deleted, and buildSshArgs then dials that alias verbatim: no -l, no -p, no Hostname. Orca connects as the wildcard's user to the wildcard's host and discards the endpoint it stored (stablyai#11746). The signal stablyai#11746 assumed (hostBlockMatch, from the still-open stablyai#11707) does not exist, and `ssh -G` cannot supply it — it prints the merged config and answers for unknown aliases too. The config file is the only source of truth, so: - parseSshConfigAliasClaims retains raw Host patterns and flags Match blocks, which parseSshConfig discards because it mints importable targets. - sshConfigMayClaimAlias is sound in the negative direction only: an unreadable file, any Match block, or any non-catch-all pattern that might match all answer "claimed", so absence of evidence is never read as evidence of absence. Only a proven-unclaimed alias licenses an override. - buildSshArgs then states Hostname/Port/User, and only those: the wildcard is still the route, and -o Hostname does not change block selection, so the proxy keeps applying and %h expands to the host we mean. The verdict is injected rather than read inside buildSshArgs, so an arg builder does not answer differently per machine. Default is today's behaviour. Scoped to the system-SSH transport and the connection's own command/transport path. Port-forward processes and the ssh2 transport (stablyai#11707) are unchanged. * fix(ssh): read a negated Host group as uncertainty, and gate clone SSH guidance `Host * !prod` applies to every alias but `prod`, yet skipping both the catch-all and the `!` pattern answered "unclaimed" for `stage` — which licences overriding Hostname/Port/User against a block the user wrote. Any negation now makes the whole group uncertain; the function is only sound in the negative direction. Also require an ssh(1) diagnostic beside "could not read from remote repository" before appending the SSH clone note: git prints that same line for the HTTP remote helper, where advice about keys and agents is simply wrong. * fix(i18n): restore the activity-options key the rebase dropped * fix(i18n): union en.json with main so the rebase cannot drop keys
|
Moving this PR to draft because it has been untouched for more than 80 days (latest recorded PR activity or commit timestamp: 2026-07-31T10:55:04Z; checked on 2026-10-27). This keeps the review queue focused on active work while preserving the proposal. Please mark it ready for review when work resumes. |
ELI5
Think of a saved SSH host as a speed-dial entry: the name
prodon the button, and the real number (10.0.0.5, port 2222, asdeploy, via thebastionswitchboard) stored behind it. Asking OpenSSH "what doesprodmean?" (ssh -G prod) never says "no such entry" — if the entry is gone it cheerfully answers with a made-up default: "call the numberprod, port 22, as whoever you are, no switchboard." We were believing that answer and throwing away everything we had stored, so tidying up~/.ssh/config(or opening Orca on another machine) silently re-pointed a saved host at a literal name that, on a corporate network with DNS search domains, can be an entirely different machine — and agent-forwarded identities were offered to it. Now we only believe the answer when it shows real evidence a Host block matched; otherwise the stored fields win.Second, smaller one: when you have several keys, we handed ssh2 the first one to hold onto. ssh2 unwraps that key immediately, so a legacy passphrase-protected
~/.ssh/id_rsablew up the whole connection before the goodid_ed25519was ever tried — you got a passphrase prompt for a key the server never asked for. Now we hand it the first key that actually opens, and still try all of them.Scope (read this first)
This PR fixes the P1 on the ssh2 transport — the path
SshConnectiontakes for every target that is not routed to system OpenSSH. It does not close the P1 on the system-SSH transport: a wildcardHost * / ProxyCommand|ProxyJumpsetsresolved.proxyCommandfor every alias, soshouldUseSystemSshTransportstill returnstruefor an evidence-less config-backed target andbuildSshArgsstill dialsconfigHostverbatim (no-l, no-p, no-o Hostname=). That half is tracked in #11746 with a proposed direction and the test matrix it needs; it is deliberately not attempted here because the one-line gate would move every wildcard-proxy user onto ssh2 wholesale.Summary
ssh -G <unknown-alias>exits 0 and prints a fully-populated default config (hostname= the alias,user= the local account,port 22, no proxy, default identity list). Since fix(ssh): preserve first config directive value #11297 every config-backed helper treated "resolved is non-null" as proof that a Host block matched.hasOpenSshHostBlockMatch(src/main/ssh/ssh-g-host-block-match.ts:37) requires positive evidence of a match — ahostnamethat is not just the echoed alias, a non-22 port, a proxy directive, or auserthat is not the local account — and only then hands OpenSSH authority.buildConnectConfiguser (src/main/ssh/ssh-connection-utils.ts:186),resolveEffectiveHost(:224),resolveEffectivePort(:234),resolveEffectiveProxy(:265, which otherwise ignoredtarget.proxyCommand/target.jumpHostentirely), and the identity paths insrc/main/ssh/ssh-auth-resolution.ts:92,102,179. When a block really matches, fix(ssh): preserve first config directive value #11297's first-directive-wins precedence is unchanged.src/main/ssh/ssh-connection.ts: the GitHub restricted-shell probe's effective user (:88, where a vanished block maderesolved.userthe local account and rejected a storedusername: 'git') and the proactive Kerberos probe (:641). The GSSAPI check keepsresolved.gssapiAuthentication === truewinning either way, so fix(ssh): preserve first config directive value #11297's distro-wide/etc/sshdefault pickup survives; the gate only stops a defaultednofrom discarding a storedgssapiAuthentication: trueand dropping a Kerberos-only host into key/password prompts.configurePrivateKeyAuthenticationnow seedsconfig.privateKeywith the first parseable candidate (src/main/ssh/ssh-private-key-authentication.ts:39-56); ssh2 parses that value eagerly inClient.connect(node_modules/ssh2/lib/client.js:258-261) and throws before anyauthHandlerruns, so an encrypted first identity killed the multi-key fallback that fix(ssh): preserve first config directive value #11297 added.authHandlerqueue (ssh2 skips unparseable queue entries rather than throwing), and an encrypted-only list still falls back tokeys[0], sofindEncryptedPrivateKeyPathand the passphrase prompt atsrc/main/ssh/ssh-connection.ts:786-800keep working.Regression source
Introduced by #11297 (5fe3aaf) — "fix(ssh): preserve first config directive value", which began trusting
ssh -Goutput unconditionally.Test plan
src/main/ssh/ssh-g-host-block-match.test.ts(10 tests), 2 new cases insrc/main/ssh/ssh-connection.test.tsfor the twossh-connection.tssites, and 3 new cases insrc/main/ssh/ssh-multi-key-authentication.test.ts.expected { host: 'prod', port: 22, … } to deeply equal { host: '10.0.0.5', port: 2222, … }; the receivedprivateKeywas~/.ssh/id_rsainstead of/keys/prodandproxywasundefinedinstead of the storedbastionjump host.expected undefined to deeply equal { kind: 'proxy-command', command: 'cf access ssh %h' }.config.privateKeywas/keys/encrypted-firstinstead of/keys/valid-second.gssapiOnlysystem-SSH probe was never spawned (Number of calls: 0).System SSH probe failed (exit 1), because the restricted-shell probe read the local account instead of the storedgit.config.usernamewaswhoeverinstead of the storeddeploy.src/main/sshtest (1089 passed / 10 skipped), the wholesrc/mainsuite (17594 passed / 49 skipped),npx oxlint src/main/ssh/,npx oxfmt --check src/main/ssh/, andtsc --noEmit -p config/tsconfig.node.json._in both word-boundary classes, soHost * / IdentityFile ~/.ssh/id_%handHost * / HostName %h_internal.example.comproduced an unmasked alias on one side and an unmasked probe token on the other →hostBlockMatch: truefor an alias with no block. Verified against OpenSSH 10.2 thatHostName %h_internal.example.comreally does expand per-alias on both probes. Fixed by dropping_from the boundary classes; 4 new parametrised cases (_-prefixed,_-suffixed,--separated,.-separated) plus aHostNamecase and a "still detects an alias-specific IdentityFile containing the alias name" guard against over-masking, all on production-shapedssh -Gbodies with the defaultidentityfilelines. The two_cases and theHostNamecase fail on the pre-fix source.resolveWithSshGcall sites asked forhostBlockEvidence: trueunconditionally, buthasOpenSshHostBlockMatchdiscards the verdict whenisOpenSshConfigBackedTargetis false — so everysource: 'manual'target and every runtime-owned target (SshConnectionStore.upsertRuntimeOwnedTargetsetssource: 'manual') paid for a secondssh -G, which re-runs the user'sMatch execmatchers, on every connect attempt and everyconnectViaSystemSsh. Now gated onisOpenSshConfigBackedTarget(this.target); 3 new cases inssh-connection.test.ts(manual, runtime-owned/no-alias, manualconnectViaSystemSsh) plus an explicithostBlockEvidence: falseexecFile-count case, all failing on the pre-fix source.src/main/sshtest (1114 passed / 10 skipped), the wholesrc/mainsuite (17619 passed / 49 skipped),npx oxlinton the changed files,npx oxfmt --check src/main/ssh/,tsc --noEmit -p config/tsconfig.node.json.User gitdirective ongithub.comcounts as a match even though HostName echoes the alias; a non-defaultPortlikewise; manual targets are untouched; and an encrypted-only identity still records the passphrase key path.Deliberately out of scope
shouldUseSystemSshTransport(src/main/ssh/ssh-connection.ts) never consultshasOpenSshHostBlockMatch, andbuildSshArgs(src/main/ssh/system-ssh-args.ts:79-83) dialsconfigHostverbatim on that branch. Executed against the branch: target{source:'ssh-config', configHost:'prod', host:'10.0.0.5', port:2222, username:'deploy'}+ resolved{hostname:'prod', user:'ops', port:22, proxyCommand:'nc -X connect …', hostBlockMatch:false}→ transporttrue, args[… ,"--","prod"]with no-l deploy/-p 2222/-o Hostname=10.0.0.5. (An earlier revision of this section claimed this case fell through to ssh2 and was "functionally equivalent" — that was wrong:resolved.proxyCommandfromHost *keeps it on the system transport, soresolveEffectiveProxyis never reached.)shouldUseSystemSshTransportnow carries a docstring pointing at [P1 follow-up] ssh: wildcard ProxyCommand/ProxyJump still dials a bare alias on the system-SSH transport #11746.resolveWithSshGdocstring rather than fixed: falsetruewhen the alias name appears as a bare token in a wildcard directive, when a negated pattern (Host !prod *) excludes it, or whenCanonicalizeHostnamerewrites only one side; falsefalsewhen a real block only restates wildcard/global values or holds directives the signature does not compare. All are no worse than the unconditionaltruethis replaced.ssh -Gbaseline fails today, so it is documented, not changed.Found by the production release scan of v1.4.163-rc.0..origin/main.
Made with Orca 🐋