cURL / Mailing Lists / curl-library / Single Mail


SFTP example or documentation

From: Mathew Simon <>
Date: Sat, 18 Aug 2007 23:44:18 -0500


Are there any example or documentation available on how to use LIBCURL
to implement a SFTP session either to upload or download a file or to
get a directory listing. I tried to use the curleasy with a URL of
sftp://..... I am able to make an initial connection to the SFTP server,
but it aborts due to some reason. The verbose output I got is quoted
below and it doesn't mean much.

Text: About to connect() to port 9922 (#0)
Text: Trying
Text: connected
Text: Connected to ( port 9922 (#0)
Text: Closing connection #0
Text: Error in the SSH layer

How do I get more info on the problem or other debugging info on the SSH
part? I am using the August-18 snapshot for both LIBCURL and LIBSSH2. I
used the following "setopts".

url = "s";
curl_easy_setopt(pCurl->mpCurl, CURLOPT_URL, url);
curl_easy_setopt(pCurl->mpCurl, CURLOPT_USERPWD, FtpUserPasswd.c_str());
curl_easy_setopt(pCurl->mpCurl, CURLOPT_PORT, 9922);
curl_easy_setopt(pCurl->mpCurl, CURLOPT_SSH_AUTH_TYPES,

Using a SFTP client program like "WinSCP", I am able to connect to that
server and hence I know that my user-ID and password work and that my
Win-XP machine, which is behind a firewall, can successfully connect to
that Server of a major company.

Mathew Simon
Received on 2007-08-19