cURL / Mailing Lists / curl-library / Single Mail


Re: libcurl scp bug? - Copying file from Cisco device

From: Mike Gibson <>
Date: Thu, 15 Aug 2013 01:50:05 -0400

Thanks for the reply. I agree, the -p seems to be the culprit. I'm looking
into how I can have libcurl call libssh2's scp_recv() with no sb struct,
and I've found this in the code:

libcurl -> ssh.c, line 2300:

In the case SSH_SCP_DOWNLOAD_INIT: block, a stat struct sb is created and
passed to libssh2_scp_recv(). Then a few lines down, the bytecount is
calculated and used for the transfer:

bytecount = (curl_off_t)sb.st_size;
Curl_setup_transfer(conn, FIRSTSOCKET, bytecount, FALSE, NULL, -1, NULL);

Now I see in transfer.h, the 3rd arg can be -1 if bytecount is unknown. So
it seems like I could take out the stat struct and setup the transfer with
-1 in place of bytecount.

Stop me now if there's a simpler way to have libssh2 not request the file
info. The only CURLOPT I could find that seemed like it might do this is
CURLOPT_FILETIME, but I don't have my development box on me now, so I'll
have to test tomorrow.

On Wed, Aug 14, 2013 at 6:22 PM, Daniel Stenberg <> wrote:

> On Wed, 14 Aug 2013, Mike Gibson wrote:
> I turned on scp debugging on the switch (debug ip scp). Every time I
>> request a file with my libcurl app, I get the following message on the
>> switch:
>> *Aug 14 17:54:19.283: SCP: [22 ->] send -p -r -d
>> options
>> not supported
> I believe it is the -p causing this specifically in this case.
> SCP is a tricky protocol in that it was never properly standardized or put
> into a spec. The client just tells the other side which command line to
> run, and it's not easy to know if the remote's scp executable support
> certain options or not!
> scp user_at_192.168.2.2:bootflash:/**cat4500-entservicesk9-mz.122-**53.SG1.bin
>> .
> Yes, but it isn't using -p then. I suspect you might get the same error if
> you try "scp -p ..." on that server.
> libcurl uses libssh2 for the SCP transfer, and libssh2 uses -p
> automatically if the user asks for it. In libssh2 API terms, that means if
> there's a struct passed in as third argument to libssh2_scp_recv(), then -p
> will be used.
> I'm wondering, what is curl doing that the scp command isn't that is
>> causing this? And how can I turn it off programmatically?
> In libcurl, don't ask libssh2 to fill in the stat struct. In libssh2, I
> think it would probably be a good idea to have it fallback to try without
> -p in case it fails with it.
> --
> /
> ------------------------------**------------------------------**-------
> List admin:**listinfo/curl-library<>
> Etiquette:**etiquette.html<>

List admin:
Received on 2013-08-15