2011-07-05 108 views
0

我已经在本地和远程之间设置了ssh密钥对。ssh密钥对连接工作,但通过ssh密钥对rsyncd要求输入密码

ssh登录工作不要求密码

[email protected] ~$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. 
[email protected] ~$ 

的rsync通过ssh非rsyncd的模式下工作(注意单:),但问题是,rsyncd.conf在该模式中没有谘询。

[email protected] ~/bin$rsync -av -e "ssh -v -l [email protected]" [email protected]:/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 
.. 
[email protected] ~/bin$ 

rsync通过ssh在rsyncd模式下失败(请注意双::),并请求密码。

[email protected] ~/bin$rsync -av -e "ssh -v -l [email protected]" [email protected]::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。

+0

你确定''l'标志'ssh'在这里吗?我认为它应该是'ssh -l user remote'或'ssh user @ remote'。 –

+0

天哪dangit ......就是这样。改成只是'ssh user @ remote'工作得很好。非常感谢。 – punkish

+0

所以我发布了这个答案,你可以接受。 –

回答

1

你确定要在这里登录-l标志吗?我认为它应该是ssh -l user remotessh [email protected]

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

1

我有类似的问题,并遇到了我的设置中的一个主要区别,它看起来在你的是一样的。

在您的SSH连接你的

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

用户密钥但rsync的连接上它是

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

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

0

这花了我几个小时才能最终追踪到,所以希望这将在未来帮助其他人。乔纳森在答复中指出,问题确实如此。您需要确保正在使用正确的SSH密钥。在我的情况下,直接使用ssh时,使用了正确的密钥。但是,rsync没有找到正确的密钥。

为了解决这个问题,叫rsync的是这样的:

rsync -avzu -e "ssh -i FULL_PATH_TO_SSH_PRIVATE_KEY" --delete SOURCE [email protected]:/DEST_PATH

诀窍是经过-i PARAM使用ssh指定的关键。