Skip to content

Commit 8f67b2e

Browse files
zoza1982claude
andcommitted
fix(ssh): try Pageant when the Windows named-pipe agent is reachable but keyless
Review fix (network-engineer, bug-bot): the Windows fallback returned as soon as the OpenSSH named-pipe agent *connected*, even on Ok(false) — so if that agent is running but empty (common; other tools auto-start it) and the user's key lives in Pageant, Pageant was never tried and auth failed. Now only a real success (Ok(true)) short-circuits; a reachable-but-keyless pipe (or a mid-auth error) falls through to Pageant. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent cb96189 commit 8f67b2e

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

crates/cairn-backend-ssh/src/connect.rs

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -309,11 +309,18 @@ async fn authenticate_agent(
309309
user: &str,
310310
) -> Result<bool, VfsError> {
311311
use russh::keys::agent::client::AgentClient;
312-
// OpenSSH's agent is the common case on modern Windows; try it first.
312+
// OpenSSH's agent is the common case on modern Windows; try it first. Only a real success stops
313+
// here: if the pipe is reachable but no key authenticates (`Ok(false)`) — or it errors mid-auth —
314+
// fall through to Pageant, where the user's key may actually live. The OpenSSH agent service is
315+
// often present but empty (auto-started by other tools), so returning on mere reachability would
316+
// strand a Pageant-held key.
313317
if let Ok(agent) = AgentClient::connect_named_pipe(r"\\.\pipe\openssh-ssh-agent").await {
314-
return agent_publickey_auth(handle, user, agent).await;
318+
if let Ok(true) = agent_publickey_auth(handle, user, agent).await {
319+
return Ok(true);
320+
}
315321
}
316-
// Otherwise fall back to a running Pageant instance.
322+
// Pageant (PuTTY) as the fallback / terminal path. If no agent was reachable at all this surfaces
323+
// as `VfsError::Auth`, matching the Unix arm when `$SSH_AUTH_SOCK` is unset.
317324
let agent = AgentClient::connect_pageant()
318325
.await
319326
.map_err(|_| VfsError::Auth)?;

0 commit comments

Comments
 (0)