Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

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?

share|improve this question
First, while debugging the problem, change the crontab entry so that it doesn't run your cron job once every minute. Next, add the command-line options -vvv to the ssh command spawned by your script. It will make SSH produce verbose diagnostic output. Update your question with that diagnostic output so we can see what's going on. –  Fran Aug 3 '12 at 14:39

Your Answer


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

Browse other questions tagged or ask your own question.