cURL / Mailing Lists / curl-library / Single Mail

curl-library

sftp help with curl-7.16.1 and libssh2-0.1

From: Mike Hanna <mikehanna_at_yahoo.com>
Date: Thu, 5 Apr 2007 17:00:25 -0700 (PDT)

Hi,

I'm trying to use curl for ftp, tftp and sftp in a linux appliance my company is working on. It's running on centos 4, so I build both the curl and libssh2 libraries on a build server and transfer them to a test machine. Ftp works fine for copying files to or from the server. Using the same code, sftp appears to connect but is having trouble opening a file for reading or writing. Here is the code I'm using to set up the transfer (same for both ftp and sftp):

    curl_easy_setopt(curl, CURLOPT_VERBOSE, TRUE);
    curl_easy_setopt(curl, CURLOPT_UPLOAD, TRUE) ;
    curl_easy_setopt(curl, CURLOPT_URL, fullurl);
    curl_easy_setopt(curl, CURLOPT_READDATA, hd_src);
    sprintf(userpwd, "%s:%s", remoteUser, remotePass);
    curl_easy_setopt(curl, CURLOPT_USERPWD, userpwd);
    curl_easy_setopt(curl, CURLOPT_SSH_AUTH_TYPES,
                     CURLSSH_AUTH_PASSWORD);

    res = curl_easy_perform(curl);

And here is the debug output:

* About to connect() to <server> port 22 (#0)
* Trying x.x.x.x... * connected
* Connected to <server info> port 22 (#0)
* User: whoever
* Password: whatever
* SSH socket: 7
* Fingerprint: * FC * 43 * 66 * BE * 51 * 84 * C7 * 10 * D3 * 6E * 96 * CB * 87 * 60 * 97 * BB *
[libssh2] Userauth: Permitted auth methods: publickey,password,keyboard-interactive
[libssh2] Userauth: Attempting to login using password authentication
[libssh2] Userauth: Password authentication successful
[libssh2] SFTP Subsystem: Initializing SFTP subsystem
[libssh2] Connection: Allocated new channel ID#0
[libssh2] Connection: Opening Channel - win 65536 pack 16384
[libssh2] Connection: Connection Established - ID: 0/0 win: 0/65536 pack: 32768/16384
[libssh2] Connection: starting request(subsystem) on channel 0/0, message=sftp
[libssh2] Connection: Window adjust received for channel 0/0, adding 131072 bytes, new window_size=131072
[libssh2] Connection: Setting blocking mode on channel 0/0 to 1
[libssh2] Connection: Setting channel 0/0 handle_extended_data mode to 1
[libssh2] SFTP Subsystem: Sending FXP_INIT packet advertising version 3 support
[libssh2] Connection: Writing 9 bytes on channel 0/0, stream #0
[libssh2] Connection: Sending 9 bytes on channel 0/0, stream_id=0
[libssh2] SFTP Subsystem: Requiring 2 packet
[libssh2] SFTP Subsystem: Asking for 2 packet
[libssh2] SFTP Subsystem: Waiting for packet: will block
[libssh2] Connection: Setting blocking mode on channel 0/0 to 1
[libssh2] Connection: Attempting to read 4 bytes from channel 0/0 stream #0
[libssh2] Connection: 9 bytes received for channel 0/0 stream #0
[libssh2] Connection: Reading 4 of buffered data from 0/0/0
[libssh2] SFTP Subsystem: Data begin - Packet Length: 5
[libssh2] Connection: Attempting to read 5 bytes from channel 0/0 stream #0
[libssh2] Connection: Reading 5 of buffered data from 0/0/0
[libssh2] Connection: Unlinking empty packet buffer from channel 0/0
[libssh2] Connection: Queing 9 bytes for receive window adjustment for channel 0/0
[libssh2] SFTP Subsystem: Received packet 2
[libssh2] SFTP Subsystem: Asking for 2 packet
[libssh2] SFTP Subsystem: Enabling SFTP version 3 compatability
[libssh2] SFTP Subsystem: Reading realpath on .
[libssh2] Connection: Writing 14 bytes on channel 0/0, stream #0
[libssh2] Connection: Sending 14 bytes on channel 0/0, stream_id=0
[libssh2] SFTP Subsystem: Waiting for packet: willnot block
[libssh2] Connection: Setting blocking mode on channel 0/0 to 0
[libssh2] Connection: Attempting to read 1 bytes from channel 0/0 stream #0
[libssh2] Failure Event: -30 - Timeout waiting for FXP packet
[libssh2] SFTP Subsystem: Asking for 104 packet
[libssh2] SFTP Subsystem: Asking for 101 packet
[libssh2] SFTP Subsystem: Waiting for packet: will block
[libssh2] Connection: Setting blocking mode on channel 0/0 to 1
[libssh2] Connection: Attempting to read 4 bytes from channel 0/0 stream #0
[libssh2] Connection: 53 bytes received for channel 0/0 stream #0
[libssh2] Connection: Reading 4 of buffered data from 0/0/0
[libssh2] SFTP Subsystem: Data begin - Packet Length: 49
[libssh2] Connection: Attempting to read 49 bytes from channel 0/0 stream #0
[libssh2] Connection: Reading 49 of buffered data from 0/0/0
[libssh2] Connection: Unlinking empty packet buffer from channel 0/0
[libssh2] Connection: Queing 53 bytes for receive window adjustment for channel 0/0
[libssh2] SFTP Subsystem: Received packet 104
[libssh2] SFTP Subsystem: Asking for 104 packet
path to open: /spaz.tar.gz
[libssh2] SFTP Subsystem: Sending file open request
[libssh2] Connection: Writing 37 bytes on channel 0/0, stream #0
[libssh2] Connection: Sending 37 bytes on channel 0/0, stream_id=0
[libssh2] SFTP Subsystem: Waiting for packet: willnot block
[libssh2] Connection: Setting blocking mode on channel 0/0 to 0
[libssh2] Connection: Attempting to read 1 bytes from channel 0/0 stream #0
[libssh2] Connection: 38 bytes received for channel 0/0 stream #0
[libssh2] Connection: Reading 1 of buffered data from 0/0/0
[libssh2] Connection: Setting blocking mode on channel 0/0 to 1
[libssh2] Connection: Attempting to read 3 bytes from channel 0/0 stream #0
[libssh2] Connection: Reading 3 of buffered data from 0/0/0
[libssh2] SFTP Subsystem: Data begin - Packet Length: 34
[libssh2] Connection: Attempting to read 34 bytes from channel 0/0 stream #0
[libssh2] Connection: Reading 34 of buffered data from 0/0/0
[libssh2] Connection: Unlinking empty packet buffer from channel 0/0
[libssh2] Connection: Queing 38 bytes for receive window adjustment for channel 0/0
[libssh2] SFTP Subsystem: Received packet 101
[libssh2] SFTP Subsystem: Waiting for packet: willnot block
[libssh2] Connection: Setting blocking mode on channel 0/0 to 0
[libssh2] Connection: Attempting to read 1 bytes from channel 0/0 stream #0
[libssh2] Failure Event: -30 - Timeout waiting for FXP packet
[libssh2] SFTP Subsystem: Asking for 102 packet
[libssh2] SFTP Subsystem: Asking for 101 packet
[libssh2] Failure Event: -31 - Failed opening remote file
libssh2_sftp_open failed
curl do failed
[libssh2] Connection: Freeing channel 0/0 resources
[libssh2] Connection: Closing channel 0/0
* Closing connection #0
* failed init

I've been banging my head on this one for a few days. Any help, tips, suggestions, info, etc. would be greatly appreciated.

Thanks,
Mike

 
____________________________________________________________________________________
We won't tell. Get more on shows you hate to love
(and love to hate): Yahoo! TV's Guilty Pleasures list.
http://tv.yahoo.com/collections/265
Received on 2007-04-06