Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SFTP using cURL

I am trying to ftp a file via sftp protocol to a client:

curl -u username --key C:\cygwin\home\XJ0002T\.ssh\id_rsa --pubkey c:\cygwin\home\XJ0002T\.ssh\id_rsa.pub -
T c:\temp2\test4.txt sftp://server/SFTP/ --insecure

Enter host password for user XJ0002T:

Curl keeps asking me for a password. I have tried key pairs using OpenSSH and puttyGen, neither worked. Can someone tell me what I am doing wrong?

like image 843
user270811 Avatar asked Apr 15 '11 21:04

user270811


People also ask

Does curl work with SFTP?

curl supports the SCP and SFTP protocols if built with a prerequisite 3rd party library: libssh2, libssh or wolfSSH.

How do I download from SFTP server using curl?

Get file using ftp or sftp protocol: $ curl ftp://ftp-your-domain-name/file.tar.gz. You can set the output file name while downloading file with the curl, execute: $ curl -o file. pdf https://your-domain-name/long-file-name.pdf. Follow a 301-redirected file while downloading file with curl, run: $ curl -L -o file.

Can you use SCP with SFTP?

You can use SSH Secure Shell, PuTTy, FileZilla or another program to connect to your server using SFTP. WinSCP can connect to your server using SCP protocol. You can even use some HTML editors to connect with SFTP like DreamWeaver.


1 Answers

Explicitly provide blank password

curl asks you for a password because you use -u and provide a username but no password.

Provide a blank password instead with -u username: (notice the trailing colon) and it will stop asking.

like image 124
Daniel Stenberg Avatar answered Oct 10 '22 08:10

Daniel Stenberg