Discussion:
SFTP example or documentation
Mathew Simon
2007-08-19 04:44:18 UTC
Permalink
Hi,

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 qa-ftp.xxx.com port 9922 (#0)
Text: Trying 66.xxx.xxx.43...
Text: connected
Text: Connected to qa-ftp.xxx.com (66.xxx.xxx.43) 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 = "sftp://qa-ftp.xxx.com";
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,
CURLSSH_AUTH_PASSWORD);

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.

Thanks,
Mathew Simon
Andre Guibert de Bruet
2007-08-19 05:23:34 UTC
Permalink
Post by Mathew Simon
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.
I do not know of one. Then again, I have not looked at the libcurl
docs or google'd for one in a while.
Post by Mathew Simon
Text: About to connect() to qa-ftp.xxx.com port 9922 (#0)
Text: Trying 66.xxx.xxx.43...
Text: connected
Text: Connected to qa-ftp.xxx.com (66.xxx.xxx.43) port 9922 (#0)
Text: Closing connection #0
Text: Error in the SSH layer
When debugging ssh-related problems, I find that running sshd with
the -d flag gives a good idea of why a connection attempt is failing
(Or succeeding!). If you need more verbose output, give it another -
d. Running with 3 -d flags is not recommended unless you are running
under script(1) or logging the output via some other mechanism, as it
produces TONS of output.
Post by Mathew Simon
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 = "sftp://qa-ftp.xxx.com";
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,
CURLSSH_AUTH_PASSWORD);
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.
This would validate that the sshd is sane. Give sshd the -d flag(s).

Cheers,

/* Andre Guibert de Bruet * 436f 6465 2070 6f65 742e 2042 6974 206a */
/* Code poet / Sysadmin * 6f63 6b65 792e 2053 7973 4164 6d69 6e2e */
/* GSM: +1 734 846 8758 * 2055 4e49 5820 736c 6575 7468 2e00 0000 */
/* WWW: siliconlandmark.com * C/C++, Java, Perl, PHP, SQL, XHTML, XML */
Daniel Stenberg
2007-08-19 20:12:11 UTC
Permalink
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 don't think we have any examples for the SSH protocols just yet, but they
should work pretty much the same way you use other protocols... The
documentation is there though.

We will appreciate all fine examples and howtos people submit!
--
Commercial curl and libcurl Technical Support: http://haxx.se/curl.html
Loading...