+1 vote
in Operating Systems by (84.8k points)

I am connecting to a server via 'ssh' in 'rsync' command. I copied the SSH public key to the server, but I am still prompted to enter password when I run 'rsync' command. How can I fix it?

Here is the command with some variables:

$RSYNC_PATH --no-compress --no-inc-recursive --delete --progress -aWe "ssh -p $RSYNC_PORT" $RSYNC_USER@$RSYNC_SERVER:$RSYNC_DIR $BACKUP_DIR

When I use SSH command without rsync, it does not ask for password.

1 Answer

+2 votes
by (358k points)
selected by
 
Best answer

If SSH works without a password prompt but rsync prompts for a password, the error could be due to how rsync is handling SSH.

Here is a quick fix for this issue:  You should explicitly mention the path to your SSH private key using the -i option of the SSH command within rsync.

$RSYNC_PATH --no-compress --no-inc-recursive --delete --progress -aWe "ssh -p $RSYNC_PORT -i ~/.ssh/id_rsa" $RSYNC_USER@$RSYNC_SERVER:$RSYNC_DIR $BACKUP_DIR

 If you have a different path for the SSH private key, replace "~/.ssh/id_rsa" with that path.

Related questions

+2 votes
1 answer
+3 votes
1 answer
+2 votes
1 answer

...