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
libssh: default id_rsa probe (since 8.22.0) stops publickey auth at the first key; the agent and other methods are never tried #23518
Since commit c7f67be ("vssh: keyfile use cleanups", 8.22.0, issue #22243) the shared helper Curl_ssh_setup_pkey() in lib/vssh/vssh.c sets the private key to $HOME/.ssh/id_rsa (then id_dsa) when the file exists and the user named no key. Both SSH backends now run this probe. They differ in what they do when that key does not authenticate.
libssh2 (lib/vssh/libssh2.c): after the key fails it continues to the agent, then keyboard-interactive, then
login denied.
libssh (lib/vssh/libssh.c): after the key fails myssh_in_AUTH_PKEY() goes to GSSAPI, then
keyboard-interactive, then password, then login denied. There is no agent step. The agent and the default keys are only reached through ssh_userauth_publickey_auto() in the else branch of myssh_in_AUTH_PKEY_INIT(), and the probe skips that branch whenever id_rsa exists. If the probed key cannot be loaded at all, myssh_in_AUTH_PKEY_INIT() returns login denied with no fallback.
So on the libssh backend the probed key is not a default, it is the only key tried. Two setups that ssh logs
into, and that curl 8.21.0 logged into, now fail.
Setup A, an unauthorized id_rsa next to the authorized key:
--key ~/.ssh/id_ed25519 works around A. Nothing on the command line works around B short of passing the
passphrase, which defeats the agent.
I am not asking to remove the id_rsa default. Issue #22243 kept it so libssh2 users keep working, and that still
holds. The gap is that the probe assumes a fallback the libssh backend does not have. Two ways to close it:
Finish the parity: on the libssh backend, after the probed key fails, continue to the agent and the remaining
methods (fall into the ssh_userauth_publickey_auto() path), the way libssh2 continues to the agent. The
default then behaves the same on both backends in the failure case.
On the libssh backend, use the probed key only when the user set CURLOPT_SSH_PRIVATE_KEYFILE, and let ssh_userauth_publickey_auto() do the default search as before 8.22.0.
Option 1 matches the goal of #22243. I can send either as a PR.
I expected the following
With no key named, a wrong or unloadable ~/.ssh/id_rsa costs one failed attempt, then curl tries the agent and the other methods the server offers, the way the libssh2 backend does. Both setups above authenticate.
Activity
icing commentedon Oct 22, 2026
Care to work on a fix for this?
saiharsha1994 commentedon Oct 23, 2026
Done. #23582
libssh: try the agent and default keys when the key file guess fails