Failing to upload using CURLSMBS

  1. last week

    John M

    Dec 1 Pre-Release Testers, Xojo Pro New York / New Jersey
    Edited last week

    I need to upload a small file to the root folder of my web site, but it isn't working using CURLSMBS. I was using the FTPKit module without any problems, but that is obsolete now in 64-bit Catalina. I'm running Xojo 2019 R2.1.

    I need to use a username and password to authenticate the upload within my app.

    I am running the MBS "CURLS ftp file upload" example project:

    dim e as integer
    dim f as folderitem
    dim d as UploadCURL  'This is subclassed from CURLSMBS, it just implements FileComplete, LoggedIn, and LoginFailed events.
    
    f=SpecialFolder.Desktop.child("TestFileToUpload")
    b = BinaryStream.Open(f)
    
    d=New UploadCURL
    d.stream = b
    d.OptionURL = "sftp://mckernon.com"
    d.OptionUpload = True
    d.OptionSSHAuthTypes = 2     '****Force using a password****
    d.OptionVerbose = True         'generate messages
    d.CollectDebugData = True    'collect them
    d.OptionInFileSize = b.Length
    d.OptionUsername = "myusername"
    d.OptionPassword = "mypassword"
    
    e = d.Perform

    If I leave the example project "as is", without the "d.OptionSSHAuthTypes=2. '****Force using a password****" line, then the web site defaults to SSH public key authentication, which fails.

    With the d.OptionSSHAuthTypes=2, then I get a "permission denied (3-31) message". I use Transmit to upload files to my web site all the time with the same username and password, so I'm baffled.

    These are the messages returned during the connection:

    Trying 107.155.86.194:22…
    TCP_NODELAY set
    Connected to mckernon.com (107.155.86.194) port 22 (#0)
    SSH MD5 fingerprint: 00b6ad7cb7f54a20293cc0834d0a6b4c
    SSH authentication methods available: publickey,password,keyboard-interactive

    *With* d.OptionSSHAuthTypes=2, it returns:

    Initialized password authentication
    Authentication complete
    Upload failed: Permission denied (3/-31)

    *Without* d.OptionSSHAuthTypes=2, it returns:

    Using SSH private key file ‘'
    SSH public key authentication failed: Unable to extract public key from private key file: Unable to open private key file

    I assume I'm missing something obvious, can anyone suggest what?

    Thank you!

  2. Christian S

    Dec 1 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Please try value 8 for keyboard interactive.

  3. John M

    Dec 1 Pre-Release Testers, Xojo Pro New York / New Jersey
    Edited last week

    That results in "Authentication failure". So I tried your "CURLS ftp file upload direct" example instead. It seems to accept the authentication, but ends with "Upload failed: Operation failed (4/-31)".

    What does this mean?

  4. Andrew L

    Dec 1 San Francisco, CA, USA

    @John M Operation failed (4/-31)

    Missing filename?

  5. John M

    Dec 1 Pre-Release Testers, Xojo Pro New York / New Jersey

    I tried using sftp://mckernon.com/CurlTesting.txt as the URL, it acts like it passed the authentication, but failed to upload.

    Is this by any chance a Catalina problem? Maybe the app needs an entitlement? Though macOS doesn't ask if the app has permission (though it does ask if it has permission to access my desktop).

  6. John M

    Dec 1 Pre-Release Testers, Xojo Pro New York / New Jersey

    I'm also wondering if it's a Catalina thing, another one of my apps is failing to send email, the same code works great on older versions of macOS.

  7. Christian S

    Dec 1 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Yes, the URL must contain the destination name.
    4/-31 is usually when URL ends in folder name.

  8. nicolás c

    Dec 2 Pre-Release Testers, Xojo Pro

    you need to use this string in the OptionURL parameter

    sftp://username:password@server_ip:port/var/www/html/files/filename.txt

  9. Christian S

    Dec 2 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    Please never put username and password in the url.

  10. nicolás c

    Dec 2 Pre-Release Testers, Xojo Pro

    how else can you indicate the user and password? is there any documentation that explains it? when using CURLS, I was not able to find that information.

  11. Christian S

    Dec 2 Pre-Release Testers, Xojo Pro, XDC Speakers, Third Party Store Germany

    See blog post:

    https://www.mbsplugins.de/archive/2018-10-14/URLs_without_UserName_and_Pass

or Sign Up to reply!