Skip to content

Hitting error -44 "Unable to ask for ssh-userauth service" with mbedtls #793

Closed

Description

@green-nsk

Describe the bug

When downloading from SFTP via libcurl, I am hitting error code -44 with description "Unable to ask for ssh-userauth service". This happens for one particular SFTP server, and others work fine.

To Reproduce

I think it has to do with server using aes256-cbc algorithm. As I have no control over the server, I'm trying to verify that assumption by changing advertised set of Ciphers on my side.

Expected behavior

I would like it to work :-D

Version (please complete the following information):

  • OS and version: Julia 1.8.5 running on Ubuntu Linux 22.04
  • libssh2 version: 1.10.0
  • crypto backend: MbedTLS

Additional context

It seems to fail to send encrypt the message before sending it. Relevant code here and here.

I have found a similar issue here which was resolved by fixing how openssl functions called here. I assume this might be a similar issue with mbedtls, but I'd be hard pressed to find out exactly what's wrong.

Activity

  1. willco007 commented on Feb 7, 2023

    @willco007
    Member

    There is one place -44 is returned and that is from LIBSSH2_ERROR_ENCRYPT in transport.c. That is from the crypt call which seems to be failing when using the mbedtls engine based on your report. You'll need to do some digging to see why it's failing.

  2. dfandrich commented on Mar 1, 2023

    @dfandrich
    Contributor

    I'm adding some end-to-end data transfer tests in PR#807 and the CI tests are showing all the following crypt methods failing with this error for MbedTLS:

    The following tests FAILED:
    	 13 - test_read_3des-cbc (Failed)
    	 14 - test_read_aes128-cbc (Failed)
    	 16 - test_read_aes192-cbc (Failed)
    	 18 - test_read_aes256-cbc (Failed)
    	 20 - test_read_rijndael-cbc (Failed)
    
  3. vszakats commented on Mar 4, 2023

    @vszakats
    Member

    @green-nsk Is this happening with mbedTLS 2.x or 3.x?

  4. green-nsk commented on Mar 6, 2023

    @green-nsk
    Author

    @vszakats it's 2.28.0 (built-in Julia one)

  5. zocterminal commented on Apr 2, 2023

    @zocterminal

    I believe I have a similar (related) issue, also with a server over which I have no control.
    This is a windows build with openssl, version libssh2 1.10 which works fine in any other regard.

    When the client (libssh2) requests the userauth service the reply packet is apparently mangled.

    In session.c at libssh2_NB_state_sent4 it calls
    _libssh2_packet_require ()
    which goes to
    _libssh2_transport_read()
    which errors out with
    LIBSSH2_ERROR_OUT_OF_BOUNDARY (-41)
    with a packet length of 878809339.

    The server works fine with OpenSSH (I debugged down there and it gets a reasonable packet).

    It's a server from a large transport company, so I guess I could share the name for debugging or do some other debugging tasks myself.

  6. zocterminal commented on Apr 2, 2023

    @zocterminal

    Upon further debugging, it appears that the remote server does not like the random padding (or libssh2 is doing something wrong with the random pad).

    Not sure what is going wrong there exactly (my understanding of the protocol at that level is woefully inadequate), but the "ssh-userauth" request is the first that is encrypted outgoing packet and the reply is the first encrypted received packet. With random padding enabled, it seems the two sides get out of sync (differing on the sent packet), so the received packet is decrypted incorrectly.

    The "fun" thing is, at least as far as I can tell, is that RANDOM_PADDING isn't set in the libssh2 itself. But in my case the source picked up the definition from a windows header (WinCrypt.h) so I'd say it got accidentally enabled.

    I'll file that as a bug separately and let the upper echelons decide if that was intended or not.

  7. vszakats commented on Apr 15, 2023

    @vszakats
    Member

    @Markus-Schmidt: can you confirm that patch #921 fixed this issue?

  8. zocterminal commented on Apr 15, 2023

    @zocterminal

    @vszakats: It does fix my version of the issue, but I'm not sure if it the same issue the original poster @green-nsk had.

    (I had initially thought these may be similar issues, so I first posted here, before opening another bug #921 after further debugging).

    But I guess the question here is more if the patch fixes the original reporter's @green-nsk issue (for example he mentions an Ubuntu in his report, so he may be affected by something else).

  9. vszakats commented on Apr 15, 2023

    @vszakats
    Member
  10. added a commit that references this issue on Feb 17, 2026
    26f57ef
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions