0

So I have a very simple rsync command that is set within a script.

rsync -avzh /mnt/data/i user@server:/mnt/data/

When I run the script manually there are no issues. When I run the script from crontab I get the following in my output:

WARNING: ECDSA key found for host server
in /home/user/.ssh/known_hosts:9
ECDSA key fingerprint 

Host key verification failed.
rsync: connection unexpectedly closed (0 bytes received so far) [sender]
rsync error: unexplained error (code 255) at io.c(600) [sender=3.0.6]

So rsync finds the ssh key but for some reason cannot use it. Now I found some questions that were for the same error and were solved. One involved running the script in cron and manually as different users. I have verified via a whoami within the script that the cron job runs as the same user that I am using to manually run the script. Another question is solved by defining where the rsync command is in the file system. This one also has been checked by running a which within the script.

Now through all of this I have noticed that rsync is using ssh to do its job. So I checked the locations of ssh within the script. Two separate locations, one in /usr/share/centrifydc/bin, when run manually, and the other in /usr/bin, when run by cron.

So this led me to checking out the .bashrc and .bash_profile to find out if that path or possibly alias is set there. It is not.

This leads me to the actual question, how can I set the /usr/share/centrifydc/bin/ssh binary as the default for the cron jobs? And if I do will it fix the issue?

Chris Woelkers
  • 155
  • 1
  • 10
  • Which OS are you running? Could you check /var/log/audit/audit.log if SELinux is denying the access? – Mircea Vutcovici Oct 13 '17 at 21:41
  • 1
    cron jobs run with a very minimal environment, especially their `$PATH`; you need to add /usr/share/centrifydc/bin (and maybe others) to it.. See my answer [here](https://stackoverflow.com/questions/6215762/mac-os-10-6-server-crontab-does-not-fire-wget-script/6216836#6216836). – Gordon Davisson Oct 14 '17 at 00:48
  • In scripts simply setting absolute paths is often the most reliable – HBruijn Oct 14 '17 at 07:44
  • Good catch on the duplicate, was focused more on rsync in a cron job than just a cron job. Turns out adding the $PATH to the script was the right way to go. To many other jobs to add it to the crontab itself. – Chris Woelkers Oct 16 '17 at 14:19

0 Answers0