2014-01-28 425 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

相關問題