Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using RCurl with SFTP

Tags:

r

sftp

rcurl

I'm attempting to use the ftpUpload in the RCurl package for the first time.

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 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"

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'

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.

like image 910
Statwonk Avatar asked Sep 04 '12 17:09

Statwonk


1 Answers

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:[email protected]: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.

like image 126
RichardE Avatar answered Nov 01 '22 18:11

RichardE