New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ssh session error with win32 build of curl.exe and libcurl connecting to sftp #11837
Comments
Is this a timing issue? If you run each build 10x do you get the same results? Could it have something to do with the way you built libssh2? If you are using the libssh2 dll use |
I just ran it 100 times through a script, and the error appears every time.
Possibly, but it happens when I link against a static libssh2 built with
Since it also happens with static linking this doesn't seem to be the issue - i checked anyway for the vcpkg version and it shows the correct dll. Is there any pre built version of libcurl (dll or static lib) that we could use? Or can we provide any other information to facilitate finding the cause of this problem |
Thanks for that. Based on the verbose output the state when the error occurs is SSH_AUTH_PKEY: Lines 1158 to 1187 in a77a4a3
Note LIBSSH2_ERROR_EAGAIN causes a break rather than show the error message diff --git a/lib/vssh/libssh2.c b/lib/vssh/libssh2.c
index 37040b4..1488739 100644
--- a/lib/vssh/libssh2.c
+++ b/lib/vssh/libssh2.c
@@ -1180,6 +1180,7 @@ static CURLcode ssh_statemach_act(struct Curl_easy *data, bool *block)
char *err_msg = NULL;
(void)libssh2_session_last_error(sshc->ssh_session,
&err_msg, NULL, 0);
+ infof(data, "libssh2_userauth_publickey_fromfile_ex error: %d\n", rc);
infof(data, "SSH public key authentication failed: %s", err_msg);
state(data, SSH_AUTH_PASS_INIT);
rc = 0; /* clear rc and continue */ I also suspect this function because you wrote earlier it doesn't matter if the key file exists or not. |
thanks for the patch, output is: |
I debugged it a little (had to remove the \n from your patch or it would throw an assert in log), and found the reason this is happening at least with libssh2 using wincng crypto backend: As this seems to be a libssh2 problem, should i open an issue there? |
what is the return code of libssh2_userauth_publickey_fromfile_ex in that case?
what is the error message curl shows you in that case? aside from your certificate issue I'm trying to determine if we're doing something wrong in curl processing the error messages or this is a libssh2 issue with not updating the error messages
Yes, please file at libssh2 and link to this issue |
Sorry for the delay,
if the path supplied via curl --key parameter points to an OpenSSH private key (or any file not containing
SSH public key authentication failed: Username/PublicKey combination invalid
first I want to try linking curl against a libssh2 with the OpenSSL crypto backend and try how that behaves, but I had linking problems, I will dig into it tomorrow - also didn't have a chance trying with curl 8.3.0 yet. |
Update: I managed to link curl 8.3.0 against libssh2 with OpenSSL crypto backend, and this solves the problem, i can connect to sftp hosts using a private key with
Since it took quite some time getting past these hurdles, i don't know when I'll have time to analyze this in detail (project deadlines approaching), but if you need any more information i'd be glad to help. |
- If libssh2_userauth_publickey_fromfile_ex returns -1 then show error message "SSH public key authentication failed: Reason unknown (-1)". When libssh2_userauth_publickey_fromfile_ex returns -1 it does so as a generic error and therefore doesn't set an error message. AFAICT that is not documented behavior. Prior to this change libcurl retrieved the last set error message which would be from a previous function failing. That resulted in misleading auth failed error messages in verbose mode. Bug: curl#11837 (comment) Reported-by: consulion@users.noreply.github.com Closes #xxxx
- If libssh2_userauth_publickey_fromfile_ex returns -1 then show error message "SSH public key authentication failed: Reason unknown (-1)". When libssh2_userauth_publickey_fromfile_ex returns -1 it does so as a generic error and therefore doesn't set an error message. AFAICT that is not documented behavior. Prior to this change libcurl retrieved the last set error message which would be from a previous function failing. That resulted in misleading auth failed error messages in verbose mode. Bug: curl#11837 (comment) Reported-by: consulion@users.noreply.github.com Closes #xxxx
I've filed #11881 to address the incorrect error messages when libssh2_userauth_publickey_fromfile_ex returns -1.
Ok. In my opinion these are libssh2 issues and you would have to file with them. #11881 is as far as I think we should take it in libcurl. |
- If libssh2_userauth_publickey_fromfile_ex returns -1 then show error message "SSH public key authentication failed: Reason unknown (-1)". When libssh2_userauth_publickey_fromfile_ex returns -1 it does so as a generic error and therefore doesn't set an error message. AFAICT that is not documented behavior. Prior to this change libcurl retrieved the last set error message which would be from a previous function failing. That resulted in misleading auth failed error messages in verbose mode. Bug: curl#11837 (comment) Reported-by: consulion@users.noreply.github.com Closes #xxxx
- If libssh2_userauth_publickey_fromfile_ex returns -1 then show error message "SSH public key authentication failed: Reason unknown (-1)". When libssh2_userauth_publickey_fromfile_ex returns -1 it does so as a generic error and therefore doesn't set an error message. AFAICT that is not documented behavior. Prior to this change libcurl retrieved the last set error message which would be from a previous function failing. That resulted in misleading auth failed error messages in verbose mode. Bug: #11837 (comment) Reported-by: consulion@users.noreply.github.com Closes #11881
- If libssh2_userauth_publickey_fromfile_ex returns -1 then show error message "SSH public key authentication failed: Reason unknown (-1)". When libssh2_userauth_publickey_fromfile_ex returns -1 it does so as a generic error and therefore doesn't set an error message. AFAICT that is not documented behavior. Prior to this change libcurl retrieved the last set error message which would be from a previous function failing. That resulted in misleading auth failed error messages in verbose mode. Bug: curl#11837 (comment) Reported-by: consulion@users.noreply.github.com Closes curl#11881
- If libssh2_userauth_publickey_fromfile_ex returns -1 then show error message "SSH public key authentication failed: Reason unknown (-1)". When libssh2_userauth_publickey_fromfile_ex returns -1 it does so as a generic error and therefore doesn't set an error message. AFAICT that is not documented behavior. Prior to this change libcurl retrieved the last set error message which would be from a previous function failing. That resulted in misleading auth failed error messages in verbose mode. Bug: curl#11837 (comment) Reported-by: consulion@users.noreply.github.com Closes curl#11881
@consulion Did you report this to libssh2? |
Hi,
we are unable to establish an sftp connection with public key authentication using the current version of curl/libcurl (8.2.1).
curl.exe from the curl website works, but the issue occurs when we build it ourselves with VS2022 (when using the solution in projects\Windows\VC14.30, using vcpkg and when building with nmake as described in winbuild/Readme.md) or using curl 8.2.1 (x86_64-w64-mingw32) which comes with mingw64.
Output of curl.exe looks like this:
interestingly, it doesn't matter if the key file exists at all, output stays the same.
When opening the same connection with libcurl (which is what we are trying to achieve), simply
CURLE_LOGIN_DENIED
is returned, the error buffer just says "Authentication failure"; i think the important bit here isSSH public key authentication failed: Would block requesting userauth list
-V
output of working curl.exe from website:-V
output of a curl.exe that shows this behaviour:Is there any way to get a version of libcurl for Windows32 that supports sftp correctly?
Could we help solving this problem somehow? Do you need any more information?
Thanks,
Ole
curl/libcurl version
curl 8.2.1
operating system
Windows 10
The text was updated successfully, but these errors were encountered: