Failing to upload using CURLSMBS

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:

[code]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
[/code]

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!

Please try value 8 for keyboard interactive.

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?

Missing filename?

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).

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.

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

you need to use this string in the OptionURL parameter

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

Please never put username and password in the url.

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.

See blog post:

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