You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
addKey() never detects the ssh-add passphrase prompt, so encrypted keys always wait 60 s (ADDKEY_TIMEOUT) #83
When keyFile points to a passphrase-protected private key, the passphrase callback is called only after about 60 seconds, on every connection.
addKey() in lib/agent.js checks the ssh-add output with rePhPrompt. That regex matches the prompt of ssh, but not the prompt of ssh-add. So addKey() never answers the prompt and fails with ADDKEY_TIMEOUT (ADDKEY_TIMEOUT_SEC = 60). Only then does ensureAgentForHost() fall back to the legacy pty auth, which finally calls the callback.
As a result, agent-based auth never works for encrypted keys, and every first connection is delayed by 60 s.
Environment
ssh-client-wrapper: 3.1.0 (observed). The same code is still in v3.3.4 (lib/util.js:44, lib/agent.js:300).
OpenSSH_9.2p1 Debian-2+deb12u10 (node:24-slim based container)
Used from OPEN-WHEEL, with passphrase set to an async callback that asks the user in the browser
Steps to reproduce
importSshClientWrapperfrom"ssh-client-wrapper";constt0=Date.now();constssh=newSshClientWrapper({host: "<host>",user: "<user>",keyFile: "/root/.ssh/id_ed25519",// passphrase-protected keypassphrase: async()=>{console.log(`passphrase callback after ${(Date.now()-t0)/1000}s`);return"<passphrase>";}});awaitssh.canConnect(120);
Results
Condition
Time until the passphrase callback
default (agent is used)
63.7 s
useAgent: false
0.31 s
reference: plain ssh shows its prompt
0.30 s
Debug log (DEBUG=sshClientWrapper:debug*):
09:43:34.085Z sshClientWrapper:debug:agent spawning shared ssh-agent at /tmp/scw-0/agent.sock
09:44:34.105Z sshClientWrapper:debug:agent agent setup did not complete (ADDKEY_TIMEOUT); using legacy pty auth
...
09:44:37.791Z sshClientWrapper:debug:fork call passphrase callback function
The unit tests do not catch this, because test/unit/agent.js (lines 133 and 170) mocks the ssh-add pty with the ssh style prompt "Enter passphrase for key '/k': ".
Workaround
Setting useAgent: false in hostInfo forces the legacy pty passphrase path, so the callback is called right away. Agent-based auth is not used in that case.
Activity