I am trying to set up curl to fetch a file from an SFTP server on my Fedora box. The command I am running is:
curl -s -S -u 'user:pass' -k 'sftp://aserver.com/afile' -o afile 2>&1
The error I am getting is:
afile: curl: (2) Failure initializing sftp session: Unable to send SSH_FXP_INIT
I can connect to the server using sftp with no errors.
Has anyone seen this before and has a workaround? Perhaps it's some curl parameter I am not setting?
Here's the output of curl -v
curl 7.20.1 (x86_64-redhat-linux-gnu) libcurl/7.20.1 NSS/3.12.8.0 zlib/1.2.3 libidn/1.16 libssh2/1.2.4
Protocols: dict file ftp ftps http https imap imaps ldap ldaps pop3 pop3s rtsp scp sftp smtp smtps telnet tftp
Features: AsynchDNS GSS-Negotiate IDN IPv6 Largefile NTLM SSL libz
Here's the trace from curl:
* About to connect() to aserver.com port 22 (#0)
* Trying 123.123.132.123...
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
0 0 0 0 0 0 0 0 --:--:-- --:--:-- --:--:-- 0 connected
* Connected to aserver.com (123.123.123.123) port 22 (#0)
* SSH authentication methods available: password,publickey,keyboard-interactive
* Using ssh public key file /home/user/.ssh/id_dsa.pub
* Using ssh private key file /home/user/.ssh/id_dsa
* SSH public key authentication failed: Unable to open public key file
* Initialized password authentication
* Authentication complete
* Failure initializing sftp session: Unable to send SSH_FXP_INIT
* Closing connection #0
curl: (2) Failure initializing sftp session: Unable to send SSH_FXP_INIT
Follow up: I gave up on curl after days of trying to get it to work. Ended up writing a fetching utility in Java using a third-party FTP/SFTP/FTPS library. Sad to say that this took me less time than I spent troubleshooting curl and the OS libraries.
--verbose– grawity Mar 17 '11 at 16:49curl -s -S -k -u user:pass sftp://address.com/but you can't download the file? – p.vitzliputzli Mar 17 '11 at 17:20sftpclient? Does the server's syslog show any errors? (Also worth trying: stop the SSH server and runsshd -rddd, for one-shot debug mode, then try curl again.) – grawity Mar 17 '11 at 18:22