"ssh_exchange_identification: Connection closed by remote host lost connection" when running cron job
        Posted  
        
            by 
                grautur
            
        on Super User
        
        See other posts from Super User
        
            or by grautur
        
        
        
        Published on 2012-08-03T10:27:04Z
        Indexed on 
            2012/11/03
            23:05 UTC
        
        
        Read the original article
        Hit count: 333
        
cron
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?
© Super User or respective owner