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?

  • 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.

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

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