Hi Owen, et al,
I believe the problem stems from the HOME variable defined in the
crontab. For example, in a default RHEL/CentOS crontab, you'll find
the following:
SHELL=/bin/bash
PATH=/sbin:/bin:/usr/sbin:/usr/bin
MAILTO=root
HOME=/
Notice that HOME is set to /. That means when Net::SSH looks for the
SSH host key, it looks in /.ssh/id_dsa, rather than /home/user/.ssh/
id_dsa. It can't find it, and it can't interactively ask for a
password, so it just says "Authentication Fails."
To make Capistrano/SSH work through Cron, you can either change that
HOME variable defined in crontab, or you can pass HOME as a command-
line environment variable, e.g., HOME=/home/user ruby my_app.rb.
James
On Aug 26, 11:30 am, OwenTran <[EMAIL PROTECTED]> wrote:
> I was getting the same issue when I ran the cap task through cron, but
> it worked fine when I was logged in as the user from the command
> line.
> There must be some sort of environment issue for your 'tools' account.
> Try creating a new account and checking or delete all
> your .ssh/.profile/etc files.
>
> Btw, I still haven't figured out how to make capistrano tasks that
> uses ssh to other machines to work properly.
>
> On Aug 26, 9:58 am, Chuck <[EMAIL PROTECTED]> wrote:
>
> > I isolated Capistrano from the environment by creating a simple
> > Net::SSH script that makes one call via ssh:
>
> > #! /usr/local/bin/ruby
>
> > require 'rubygems'
> > require 'net/ssh'
>
> > Net::SSH.start('host1', 'tools') do |ssh|
> > output = ssh.exec!("hostname")
> > puts output
> > end
>
> > This is where all the issues lie, as I get exactly the same error.
>
> > Still digging...
>
> > On Aug 22, 4:47 pm, Chuck <[EMAIL PROTECTED]> wrote:
>
> > > Capistranowas working extremely well until a few weeks back. We have
> > > been unable to determine what change has caused our sudden connection
> > > failures. When the SSH command is run manually on the command line, it
> > > succeeeds without complaint. When the exact same command is run via a
> > > task, it fails:
>
> > > [EMAIL PROTECTED]:/var/www/brews> cap -S deploy_type=dr deploy:cron:show
> > > * executing `deploy:cron:show'
> > > * executing "crontab -l"
> > > servers: ["host2.domain.net", "host3.domain.net"]
> > > connection failed for: host2.domain.net (Net::SSH::Disconnect:
> > > connection closed by remote host), host2.domain.net
> > > (Net::SSH::Disconnect: connection closed by remote host)
>
> > > [EMAIL PROTECTED]:/var/www/brews> ssh host2 "crontab -l"
> > > #####################################################################
> > > # min hours date month weekday #
> > > # 0-59 0-23 1-31 1-12 0-6 (where 0 is Sunday) #
> > > # #
> > > # NOTE: Terminate every line with a '%' to indicate the command #
> > > # ends with a newline (\n) character. #
> > > #####################################################################
> > > ...
>
> > > Even more interesting, theCapistranotask will succeed if it is
> > > executed by some account OTHER than "tools," following a standard
> > > password prompt.
>
> > > Capistranov2.4.3
> > > Net::SSH v2.0.3
>
> > > This one is making me crazy!
>
> > > Chuck
--~--~---------~--~----~------------~-------~--~----~
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at http://groups.google.com/group/capistrano
-~----------~----~----~----~------~----~------~--~---