在 SFTP 中使用 RCurl [英] Using RCurl with SFTP
问题描述
我第一次尝试使用 RCurl 包中的 ftpUpload
.
I'm attempting to use the ftpUpload
in the RCurl package for the first time.
我尝试访问的站点使用 sftp 协议.我已确保安装包含安全连接功能的 libcurl 版本.
The site I'm trying to access uses the sftp protocol. I've made sure to install the version of libcurl that includes the ability to make secure connections.
SFTP 列在 RCurl 可用的协议中:
SFTP is listed among the protocols available to RCurl:
curlVersion()$protocols
[1] "dict" "file" "ftp" "ftps" "gopher"
[6] "http" "https" "imap" "imaps" "ldap"
[11] "pop3" "pop3s" "rtmp" "rtsp" "scp"
[16] "sftp" "smtp" "smtps" "telnet" "tftp"
然而,当我运行 fileUpload
函数时,我得到:
Yet, when I run the fileUpload
function I get:
ftpUpload(what = "some_file.png",
to = "userid:password@sftp://ec2-some-server-ip.compute-1.amazonaws.com")
Error in function (type, msg, asError = TRUE) :
Couldn't resolve host 'sftp'
我还尝试在参数化方面打破 userid
和 password
,但得到相同的响应.
I have also tried breaking the userid
and password
out in terms of parameterization, but I get the same response.
如有任何建议,我们将不胜感激.
Any suggestions would be appreciated.
推荐答案
用户 ID 和密码需要在协议之后(这就是为什么你会收到找不到主机 sftp 错误的原因):
The userid and password need to be after the protocol (thats why you're getting the cannot find host sftp error):
ftpUpload(what = "some_file.png",
to = "sftp://userid:password@ec2-some-server-ip.compute-1.amazonaws.com:22/path/some_file.png")
我还建议在主机后面加上端口号,以防它不是默认的,以及你希望它去的服务器上的文件路径.
I also suggest including the port number after the host in case it's not the default and the file path on the server where you want it to go.
这篇关于在 SFTP 中使用 RCurl的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!