Password SSH authentication method in RCurl

时光总嘲笑我的痴心妄想 提交于 2019-12-01 01:07:49

It seems a little late, but I am currently trying something similar (public key authentication, though) and got it working! Here is what I did:

I did set up a public key authentication basically following the instructions at http://www.howtoforge.com/set-up-ssh-with-public-key-authentication-debian-etch

That is, I run on the server the command

ssh-keygen -t rsa -C "e@mail.com" -f "ir_rsa"

to generate a public and a private key. (Just as a sidenote, I first tried to use puttygen on my local windows machine to create working keys but failed.)

Then I add the public key to the authorized keys (still on the remote server)

mkdir ~/.ssh
chmod 700 ~/.ssh
cat id_rsa.pub >> ~/.ssh/authorized_keys
chmod 600 ~/.ssh/authorized_keys

and copy both the public and private key file on the local machine where R is running. Then I can upload a file from R using

require(RCurl)
ftpUpload(what = "myfile.txt",
    to = "sftp://myusername@my.host.com:22/path/to/myfile",
    verbose = TRUE,
    .opts = list(
        ssh.public.keyfile = "path/to/local/pubkeyfile", 
        ssh.private.keyfile = "path/to/local/privatekeyfile"
    ) 
)
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!