I have tested my SSH authentication using PuTTY
with success, which I mean I can ssh
to remote server using the private key provided. However, I am trying to use SCP
function from Rcurl
package in R, I got the error message saying:
Error in function (type, msg, asError = TRUE) : Authentication failure
Here is my code
r <- scp(host='eee.com', path = "/aaa/bbb/test.sas7bdat",
keypasswd = NA, user = "yyyyyy", rsa = TRUE,
key = "C:/Users/.ssh/authorized_keys", binary = NA)
C:/Users/.ssh/authorized_keys
is my private RSA key.
I have had the same problem and did not get scp
to work, but found a workaround in getURLContent
:
x <- getURLContent("sftp://path/file", .opts = list(
ssh.private.keyfile = "path/keyfile",
username="username",
keypasswd="password"))
And the private key should be an openSSH key (I had to convert my puttygen key) and while I had to download binary content I used getBinaryURL
in the end with the same arguments.
the problem is that "key" must contain both the public and the private key. This should work:
r <- scp(host='eee.com', path = "/aaa/bbb/test.sas7bdat", keypasswd = NA, user = "yyyyyy", rsa = TRUE, key = c("C:/Users/.ssh/authorized_keys.pub","C:/Users/.ssh/authorized_keys"), binary = NA)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.