开发者

ssh key pair connection works, but rsyncd over ssh key pair asks for password

开发者 https://www.devze.com 2023-03-18 17:41 出处:网络
I have set up ssh key pair between local and remote. ssh login works without asking for password user@local ~$ssh -v remote

I have set up ssh key pair between local and remote.

ssh login works without asking for password

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 works in non-rsyncd mode (note single :), but the problem is that rsyncd.conf is not consulted in this mode.

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 interacti开发者_开发技巧ve session.
debug1: Sending command: rsync --server --sender -vlogDtpre.iLs . /dir
receiving file list ... done
..
user@local ~/bin$

rsync over ssh in rsyncd mode fails (note double ::), and password is requested.

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:

What am I doing wrong? My objective is to run rsync using rsyncd.conf on the remote machine.


Are you sure about the -l flag to ssh here? I think it should either be ssh -l user remote or ssh user@remote.

I know nothing about rsync and its use of ssh, so I can't really say why it works in one version and not in the other one.


I was having a similar issue and came across one major difference in my setup and it looks to be the same in yours.

On your ssh connection you have a user key of

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

But on the rsync connection it is

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

You need to make sure the key file is generated for the user that you are running the rsync command with.


This took me hours to finally track down, so hopefully this will help others in the future. The problem indeed was as Jonathan pointed out in his answer. You need to ensure that the correct SSH key is being used. In my case, when using ssh directly, the correct key was used. However, rsync was NOT finding the correct key.

To solve it, call rsync like this:

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

The trick is passing the -i param with ssh specifying the key.

0

精彩评论

暂无评论...
验证码 换一张
取 消