Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to download file with curl from sftp server

Tags:

curl

xml

I need to download .xml file for SFTP server. When i used command sftp://username:password@%ipaddress/ram//abc.xml....it was working.

Requirement is to download for Multiple IP address.I tried to use it with curl to download via command curl -f -m 600 -o temp.xml sftp://username:password2%1/ram/abc.xml. %1 is a text file which contains multiple iP address.

BUT it is not working....Could anybody suggest change in command ...thanks

like image 292
user3244207 Avatar asked Nov 18 '25 15:11

user3244207


1 Answers

You can grab file securely from an SSH server using SFTP:

curl -u username sftp://server1.cyberciti.biz/path/to/file.txt

OR (note ~ means your $HOME)

curl -u vivek sftp://home1.cyberciti.biz/~/docs/resume.pdf

You can grab a file from an SSH server using SCP using a private key to authenticate.
The syntax is:

curl -u username: --key ~/.ssh/id_rsa --pubkey ~/.ssh/id_rsa.pub scp://home1.cyberciti.biz/~/Videos/rhn_register.ogv

Where,

`-u username` - Specify the user name (and optional password) to use for server authentication.
`-u username:password` - Specify the user name (and optional password) to use for server authentication.
`--key ~/.ssh/id_rsa` - SSL or SSH private key file name. Allows you to provide your private key in this separate file.
`--pubkey ~/.ssh/id_rsa.pub` - SSH Public key file name. Allows you to provide your public key in this separate file.
scp://home1.cyberciti.biz/~/Videos/rhn_register.ogv - Use scp protocol and download file from my home server called home1.cyberciti.biz.
like image 133
Pedro Lobito Avatar answered Nov 21 '25 08:11

Pedro Lobito



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!