Search code examples
rsshscp

SSH/SCP using R from a windows machine


I'm trying to write a R script (on a windows machine) that runs a remote shell command via SSH, then yanks a file using scp and manipulates it.

ssh.utils won't run on windows, RCurl keeps throwing "authentication failure":

 #Failed attempt:
    file <- scp(host = "1.2.3.4", path = "/path-to-file", key = "~/../Desktop/id_rsa.pub", user = "admin", keypasswd = "")

messages, even though I'm referencing it to the correct public rsa key.

Any ideas how to make this work?


Solution

  • scp(host = "1.2.3.4", path = "/path-to-file", key = "~/../Desktop/id_rsa.pub", user = "admin", keypasswd = "")
                                                                      ^^^^^^^^^^
    

    I don't work with R, but it's likely that you're using the wrong key file here. When you use a key file with an ssh client, you normally supply the private key file, not the public key file. In this case your private key file is probably named ".../id_rsa" without the ".pub" extension.