0

What's wrong with this code?

sudo -u replicant rsync -av -e "ssh -o 'StrictHostKeyChecking no' -i /home/replicant/.ssh/id_rsa" --exclude 'media/' --exclude 'var/' --exclude '.svn' root@$ADMIN:/var/www/ /var/www/ &> /tmp/rsync
if
[ $? -ne 0 ]; then
echo "date: Error rsync'ing code base from $ADMIN check /tmp/rsync" | mail -s "Rsync error!" $DEVEMAIL
echo "date: Error rsync'ing code base from $ADMIN check /tmp/rsync" >> $LOGFILE
echo "root@$ADMIN:/var/www /var/www" >> $LOGFILE
exit
fi

I keep getting this error:

Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: unexplained error (code 255) at io.c(605)
[Receiver=3.0.9]

Please help. Thanks.

1
  • Late reply, but it sounds like your SSH key was not accepted by the remote server, check it's the right public key and that it's readable by the replicant user Feb 15, 2013 at 14:55

1 Answer 1

0

Try to login directly on SSH to fix your issues, then move on to your rsync test. So start with:

ssh -o 'StrictHostKeyChecking no' -i /home/replicant/.ssh/id_rsa root@$ADMIN

Sidenotes:

  • don't use root for such a task
  • add set -eu at the start of your Bash script, so that errors will end up your script and ease debugging (for example if $ADMIN is not defined, the script will end in error)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.