Hi I am trying to backup an ubuntu 16.04 server to a freeNAS backup server using rsync and crontab.

The command I am using for rsync is

sudo rsync --delete --delete-excluded -az /home/backups/ root@

When I run this command from command line first it asks for sudo password then root password for Then command is executed as expected.

when I try to sudo ssh root@ then also it asked for both passwords. I have tried to use sudo ssh-copy-id root@ and have copied the keys successfully.

My question is

  1. How do I bypass password entry
  2. when I run rsync command with crontab I am getting wrong password errors

How do I correct these?


First, do Not try to use sudo in a cron job. sudo has nowhere to prompt for the password.

Run your command in root's crontab - the /etc/crontab file. Edit this file directly, Not with sudo crontab -e. The /etc/crontab file has a non-standard format, so read the comments at the front of the file carefully.

# /etc/crontab: system-wide crontab
# Unlike any other crontab you don't have to run the `crontab'
# command to install the new version when you edit this file
# and files in /etc/cron.d. These files also have username fields,
# that none of the other crontabs do.
  • 1
    What's wrong with sudo crontab -e? That actually edits root's crontab whereas /etc/crontab is the system-wide crontab. – PerlDuck Mar 11 '18 at 8:49

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.