【问题标题】:Password SSH authentication method in RCurlRCurl 中的密码 SSH 身份验证方法
【发布时间】:2012-09-05 18:34:01
【问题描述】:

我正在使用RCurl 包中的ftpUpload 函数将文件上传到sftp 文件服务器。我在进行身份验证调用时遇到了困难。

以下是我的电话:

ftpUpload(what = "some-file.png",
      to = "sftp://some-ftp-server.com:22/path/to/some-file.png",
      verbose = TRUE,
      userpwd = "my_userid:my_password")

结果我得到:

* About to connect() to some-ftp-server.com port 22 (#0)
*   Trying some-ftp-server.com... * connected
* Connected to some-ftp-server.com (some ip address) port 22 (#0)
* SSH authentication methods available: publickey,password
* Using ssh public key file /home/.ssh/id_dsa.pub
* Using ssh private key file /home/.ssh/id_dsa
* SSH public key authentication failed: Unable to open public key file
* Authentication failure
* Closing connection #0
Error in function (type, msg, asError = TRUE)  : Authentication failure

我不是设置 sftp 服务器的人,而且我有点 ssh 菜鸟——抱歉。我所知道的是,我可以通过 Filezilla 使用 my_useridmy_password 登录,并且服务器有一个 .htaccess.htpasswd 文件。

我希望有某种方法可以使用ftpUpload 仅使用我的用户名和密码进行身份验证。似乎password 是两种可用方法之一,但我似乎无法让ftpUpload 理解我想单独使用后者。

.htpasswd 文件似乎包含my_userid:my_password,但密码部分已加密。我愿意将其加载到某个位置以供ftpUpload 访问,但我不确定如何将ftpUpload 指向正确的方向。

最后,我尝试使用并查看此处列出的 libcurl 选项:http://www.omegahat.org/RCurl/philosophy.html 并在此处进行更全面的解释:http://curl.haxx.se/libcurl/c/curl_easy_setopt.html

唉,运气不好。任何帮助表示赞赏!

【问题讨论】:

    标签: r rcurl


    【解决方案1】:

    这似乎有点晚了,但我目前正在尝试类似的东西(虽然是公钥身份验证)并且让它工作了! 这是我所做的:

    我确实按照http://www.howtoforge.com/set-up-ssh-with-public-key-authentication-debian-etch 的说明设置了公钥身份验证

    也就是说,我在服务器上运行命令

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

    生成公钥和私钥。 (作为旁注,我首先尝试使用 puttygen 在我的本地 Windows 机器上创建工作密钥但失败。)

    然后我 将公钥添加到授权密钥(仍在远程服务器上)

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

    并在本地机器上复制公钥和私钥文件 R 正在运行。然后我可以使用从 R 上传文件

    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"
        ) 
    )
    

    【讨论】:

      猜你喜欢
      • 2023-03-18
      • 1970-01-01
      • 2019-08-26
      • 2020-09-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多