cURL / Mailing Lists / curl-library / Single Mail


RE: Why curleasy do nothing for SFTP

From: Mathew Simon <>
Date: Sun, 19 Aug 2007 23:38:27 -0500

The "sftp_nonblock.c" or the other example programs of LIBSSH2 are not
meant for the Mingw32 platforms. But after some tinkering I was able to
compile the "sftp_nonblock.c" under Mingw32 and execute it. By the way,
the rc = ioctlsocket(sock, FIONBIO, 1) may be used under Mingw32 to get
it compiled under Mingw32.

#ifdef F_SETFL
    /* FIXME: this can/should be done in a more portable manner */
    rc = fcntl(sock, F_GETFL, 0);
    fcntl(sock, F_SETFL, rc | O_NONBLOCK);
    rc = ioctlsocket(sock, FIONBIO, 1);
//#error "add support for setting the socket non-blocking here"

Using the "sftp_nonblock.c", I was able to log-in to the sshd server
using password authentication, and to me it is very good progress
compared to what the LIBCURL is able to achieve. With a little more
tinkering, I might be able to transfer a file. But it may not help me to
get SFTP in curleasy work for me.

I tried my best with curleasy, by using different setopts options, to
get it login-in to the sshd server. It conveys the user name to the sshd
server, since the sshd server is getting ready to authenticate that
user. But somehow the authentication do not take place, and the
connection is dropped by the client. Is the password not getting passed
to the sshd server? I tried the key-board authentication in the setopt,
and I don't get any action either. That is, it is not asking me to
key-in the password.

I am sure that the sshd server is behaving correctly, since a SFTP
client software like the "WinSCP" is able to login and transfer files
between the server and the Windows client machine. Hence, the chances of
a broken sshd server can be ruled out.

I couldn't use my debugger (Codeblocks IDE + gdb) for tracing
"sftp_nonblock.c" since it keep dying with sigserv messages. I couldn't
trace into LIBCURL since I didn't compile LIBCURL and LIBSSH2 with the
debug option. Even if I manage to create a debugging compilation of
these libraries, my debugger will fail on non-native windows code.

Any input on how I can proceed to get the curleasy to do SFTP, will be

Mathew Simon

From: Daniel Stenberg <>
Date: 2007-08-19

On Sun, 19 Aug 2007, Mathew Simon wrote:

> Text: Error in the SSH layer
> What is preventing CURL from attempting to take the connection to the
> level or log-in? How can I go from here?

You run a libssh2 example program (like sftp_nonblock.c) against the
and verify that it downloads the file fine. If not, start debugging
that. If it does transfer fine with the example, use a debugger to see
the difference is between sftp_nonblock's and libcurl's way of using
Received on 2007-08-20