【问题标题】:ssh key pair connection works, but rsyncd over ssh key pair asks for passwordssh 密钥对连接有效,但 ssh 密钥对上的 rsync 要求输入密码
【发布时间】:2011-07-05 19:18:43
【问题描述】:

我已经在本地和远程之间设置了 ssh 密钥对。

ssh 登录无需输入密码

user@local ~$ssh -v remote
..
debug1: Authentications that can continue: publickey..
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/user/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).
..
debug1: Entering interactive session.
user@remote ~$

rsync over ssh 在非 rsyncd 模式下工作(注意单 :),但问题是在此模式下不咨询 rsyncd.conf。

user@local ~/bin$rsync -av -e "ssh -v -l user@remote" user@remote:/dir
..
debug1: Authentications that can continue: publickey..
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/punkish/.ssh/id_rsa
debug1: Server accepts key: pkalg ssh-rsa blen 277
debug1: Authentication succeeded (publickey).
..
debug1: Entering interactive session.
debug1: Sending command: rsync --server --sender -vlogDtpre.iLs . /dir
receiving file list ... done
..
user@local ~/bin$

在 rsyncd 模式下通过 ssh 进行 rsync 失败(注意双 ::),并且需要密码。

user@local ~/bin$rsync -av -e "ssh -v -l user@remote" user@remote::module
..
debug1: Authentications that can continue: publickey..
debug1: Next authentication method: publickey
debug1: Offering public key: /Users/punkish/.ssh/id_rsa
debug1: Authentications that can continue: publickey..
debug1: Next authentication method: keyboard-interactive
Password:

我做错了什么?我的目标是在远程机器上使用 rsyncd.conf 运行 rsync。

【问题讨论】:

  • 你确定-l 标志到ssh 这里吗?我认为应该是ssh -l user remote 或ssh user@remote。
  • Gosh dangit...就是这样。更改为 ssh user@remote 效果很好。非常感谢。
  • 所以我发布了这个作为答案,你可以接受。

标签: ssh rsync


【解决方案1】:

你确定这里有 ssh 的 -l 标志吗?我认为应该是ssh -l user remote 或ssh user@remote。

我对 rsync 及其对ssh 的使用一无所知,所以我真的不能说为什么它在一个版本中有效,而在另一个版本中无效。

【讨论】:

    【解决方案2】:

    我遇到了类似的问题,并且在我的设置中遇到了一个主要差异,而在您的设置中看起来是一样的。

    在您的 ssh 连接上,您有一个用户密钥

    debug1: Offering public key: /Users/user/.ssh/id_rsa
    

    但是在 rsync 连接上是

    debug1: Offering public key: /Users/punkish/.ssh/id_rsa
    

    您需要确保为运行 rsync 命令的用户生成密钥文件。

    【讨论】:

      【解决方案3】:

      这花了我几个小时才最终找到,所以希望这会在未来对其他人有所帮助。问题确实正如乔纳森在回答中指出的那样。您需要确保使用了正确的 SSH 密钥。就我而言,直接使用 ssh 时,使用了正确的密钥。但是,rsync 没有找到正确的密钥。

      要解决它,请像这样调用 rsync:

      rsync -avzu -e "ssh -i FULL_PATH_TO_SSH_PRIVATE_KEY" --delete SOURCE USER@HOST:/DEST_PATH

      诀窍是通过指定密钥的 ssh 传递 -i 参数。

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 2014-02-01
        • 2014-12-11
        • 2019-10-04
        • 1970-01-01
        • 2019-09-26
        • 1970-01-01
        • 2013-09-18
        相关资源
        最近更新 更多