Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm running on a Mac, and I want to set up a crontab to rsync from my VPS on a weekly basis to grab some backup archives. I'm using ssh keys (no passwords allowed on the VPS), and normally I can ssh in without any prompts (my private key has a passphrase but it's stored in the Mac keychain). However, when cron runs a script, it fails and emails me saying that ssh failed:

Permission denied (publickey).
rsync: connection unexpectedly closed (0 bytes received so far) [receiver]
rsync error: unexplained error (code 255) at /SourceCache/rsync/rsync-42/rsync/io.c(452) [receiver=2.6.9]

The script being executed:

rsync -Cavz -e "ssh -i /Users/bob/.ssh/id_rsa" bob@myvps:/backups/ ~/Documents/Backups

What am I doing wrong?

share|improve this question
It's failing on the authentication. Likely to do with the passphrase imo. – Peter Apr 17 '13 at 9:24

I don't think that cron has access to your passphrase and that's why you cannot log into your remote server. The best way to achieve this is to set up a new key with no passphrase.

Using a key without a passphrase is less secure but you can however limit its usage. See *AUTHORIZED_KEYS FILE FORMAT* section in the sshd manual.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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