"ssh_exchange_identification: Connection closed by remote host lost connection" when running cron job
- by grautur
I have a Ruby script that connects to a remote machine via ssh and executes a command. The script runs fine when I just run it in my terminal. In my crontab, I have
1 * * * * /bin/bash -l -c 'ruby myfile.rb'
and if I go ahead and run /bin/bash -l -c 'ruby myfile.rb', everything executes fine.
But when cron itself executes the job, I get a
ssh_exchange_identification: Connection closed by remote host
error. What's the cause of this? How do I fix it?