Search code examples
sftprcurl

RCurl sftp connection with proxy


I have been trying to connect and list files with RCurl and SFTP. I can access this via WinSCP, but RCurl won't go through. Here is where I'm currently:

library(RCurl)

opts <- curlOptions(
  proxy         = "http://myproxy/",
  proxyport     = 8080,
  httpproxytunnel = 1L,
  ssh.private.keyfile = "ssh-gibberish"
)

url <- "sftp://user:pwd@ftp.address.com/"

test <- getURL(url = url, .opts = opts, dirlistonly = TRUE, verbose = TRUE, port = 22)

*   Trying 123.12.123.12...
* Connected to myproxy (123.12.123.12) port 8080 (#0)
* Establish HTTP proxy tunnel to ftp.address.com:22
> CONNECT ftp.address.com:22 HTTP/1.1
Host: ftp.address.com:22
Proxy-Connection: Keep-Alive

* Proxy CONNECT aborted
* Connection #0 to host myproxy left intact
Error in function (type, msg, asError = TRUE)  : Proxy CONNECT aborted

Solution

  • Finally solved it. I had to change proxy and add username and password.

    opts <- curlOptions(
      proxy         = "http://mynewproxy/",
      proxyport     = 8080,
      proxyusername = "domain\\user", 
      proxypassword = "pwd", 
      httpproxytunnel = 1L,
      ssh.private.keyfile = "ssh-gibberish"
    )
    

    Normally proxy uses windows passowrds, but I quess this is different.