我正在用 R 编写一些需要使用 SSH 密钥身份验证将文件上传到服务器的内容。我正在使用 RCurl 包中的以下代码,但我使用的私钥有密码。对于我的一生,我无法弄清楚如何为密钥指定密码。有没有人有使用 ftpUpload 函数的经验,或者在 R 中可能有更好的方法?
ftpUpload(what = pathtofile,
to = serverlocation,
verbose = TRUE,
.opts = list(
ssh.private.keyfile = pathtokey
))
从curlOptions的 R 文档并运行listCurlOptions()
它看起来keypasswd
就是你正在寻找的。
编辑/更新:我尝试将此选项添加到我自己的代码中并运行它,它对我来说很好用。您的最终调用应如下所示:
ftpUpload(what = pathtofile,
to = serverlocation,
verbose = TRUE,
.opts = list(
ssh.private.keyfile = pathtokey,
keypasswd = passphrase
))
你的输出应该是这样的:
* Trying 123.456.789…
* TCP_NODELAY set
* Connected to 123.456.789 (123.456.789) port 22 (#0)
* SSH MD5 fingerprint: abcdefghij123456789
* SSH authentication methods available: publickey
* Using SSH public key file '/Users/User1/.ssh/id_rsa.pub'
* Using SSH private key file '/Users/User1/.ssh/id_rsa'
* Initialized SSH public key authentication
* Authentication complete
* Connection #0 to host 123.456.789 left intact
OK
0
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句