Buy commercial curl support from WolfSSL. We help you work out your issues, debug your libcurl applications, use the API, port to new platforms, add new features and more. With a team lead by the curl founder himself.

Re: libcurl configuration for sftp

From: Michael Loutris via curl-library <curl-library_at_cool.haxx.se>
Date: Mon, 19 Oct 2020 10:40:30 -0500 (CDT)

> On 10/14/2020 9:46 AM Dan Fandrich via curl-library <curl-library_at_cool.haxx.se> wrote:
>
> On Wed, Oct 14, 2020 at 09:06:14AM -0500, Michael Loutris wrote:
> > > On 10/14/2020 12:35 AM Dan Fandrich via curl-library <curl-library_at_cool.haxx.se> wrote:
> > >
> > > On Tue, Oct 13, 2020 at 06:42:50PM -0500, Michael Loutris via curl-library wrote:
> > > > I am trying to securely transfer a file between two windows 10 devices, and I
> > > > get error 67, "CURLE_LOGIN_DENIED" when calling curl_easy_perform(). All of
> > > > the curl_easy_setopt() calls return success.
> > > >
> > > > The server has been configured as an SSH server using OpenSSH for Windows 10
> > > > and using OpenSSH commands from a Windows command prompt are successful in
> > > > transferring files.
> > >
> > > When you use these commands, does the logging show that authentication is
> > > performed with username+password, or is it being done with a key? Is the key
> > > encrypted on disk?
> > >
> > > Dan
> > > -------------------------------------------------------------------
> > Logging shows that authentication is done with a non-encrypted key.
>
> Good—that proves the key is working. Next, I'd confirm that there's not a
> compatibility issue with the ssh backend you're using. Which one is that? For
> example, recent OpenSSH has disabled many protocols supported by libssh2 and it
> sometimes has trouble negotiating a compatible one. Can you connect to the
> server using the appropriate command-line tool associated with the backend in
> use? For example, can you do an sftp download using the examples/sftp program
> in libssh2 (using the same library version as your libcurl and changing the
> keyfile* variables appropriately)?
> ------------------------------------------------------------------
I grabbed the libssh2.dll and generated a .lib for Windows and was able to successfully transfer a file.
I suspect that my issue has to do with properly formatting the strings to libcurl, and for Windows in particular.

1. I want to set the remote port for SFTP, so I believe that I should *NOT* user CURLOPT_CONNECT_TO, but use CURLOPT_RESOLVE, correct?

2. The SSH/SFTP connection lies on an internal network, with no DNS or domain names. In the CURLOPT_RESOLVE description, the curl_slist string has the format HOST:PORT:ADDRESS
Should I leave the HOST empty or repeat the address?
Which of the following formats do I use, ":22:10.20.30.40" or "10.20.30.40:22:10.20.30.40"?

3. When setting up the CURLOPT_URL, I need to connect to the server to a user account on the D: drive.
I tried using the following call, but I'm afraid that it might be malformed. Again, this is for SFTP between two Windows 10 machines.

  result = curl_easy_setopt( curlSessionHandle, CURLOPT_URL, "sftp://wi-19981-rda_at_10.35.78.113/~/Users/wi-19981-rda/Device_A/some_file" );

I tried converting the slashes to the Windows format
    "sftp:\\wi-19981-rda_at_10.35.78.113\\~\\Users\\wi-19981-rda\\Device_A\\some_file"
but then libcurl signals a protocol error.

I'm already specifying the protocol in another option call, so is it necessary to specify the protocol in the CURLOPT_URL call as well?

4. Does the D: drive need to be explicitly listed in the path, or is it enough to use the /~/?

-------------------------------------------------------------------
Unsubscribe: https://cool.haxx.se/list/listinfo/curl-library
Etiquette: https://curl.haxx.se/mail/etiquette.html
Received on 2020-10-19