2014-01-28 428 views
0

我需要为SFTP server下载.xml文件。 当我使用命令sftp://username:[email protected]%ipaddress/ram//abc.xml ....它工作。如何使用curl从sftp服务器下载文件

要求下载多个IP地址。我试着用curl来通过命令 curl -f -m 600 -o temp.xml sftp://username:password2%1/ram/abc.xml下载。 %1是一个包含多个iP地址的文本文件。

但它不工作....可能有人建议在命令变化...感谢

回答

2

您可以安全地从一个SSH服务器使用SFTP抢文件:

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

OR(注〜意味着您的$ HOME)

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

您可以使用SCP从SSH服务器使用私钥获取文件进行身份验证。
的语法是:

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

`-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. 
+1

卷曲:(1)协议 “SFTP” 不支持或libcurl中禁用 – jliles

相关问题