在 R 中使用 ftpUpload 函数的私钥密码
Passphrase for private key using ftpUpload function in R
我正在用 R 编写一些东西,需要使用 SSH 密钥身份验证将文件上传到服务器。我正在使用 RCurl 包中的以下代码,但我使用的私钥有一个密码。对于我的生活,我无法弄清楚如何指定密钥的密码。有没有人有使用 ftpUpload 函数的经验,或者可能有更好的方法在 R 中执行此操作?
ftpUpload(what = pathtofile,
to = serverlocation,
verbose = TRUE,
.opts = list(
ssh.private.keyfile = pathtokey
))
从 curlOptions 和 运行 listCurlOptions()
的 R 文档看来,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
我正在用 R 编写一些东西,需要使用 SSH 密钥身份验证将文件上传到服务器。我正在使用 RCurl 包中的以下代码,但我使用的私钥有一个密码。对于我的生活,我无法弄清楚如何指定密钥的密码。有没有人有使用 ftpUpload 函数的经验,或者可能有更好的方法在 R 中执行此操作?
ftpUpload(what = pathtofile,
to = serverlocation,
verbose = TRUE,
.opts = list(
ssh.private.keyfile = pathtokey
))
从 curlOptions 和 运行 listCurlOptions()
的 R 文档看来,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