capistrano gets “failed password” when accessing git repository server
Hi,
This one concerns using capistrano for Rails deployment, and git for version control. I got stuck for quite some time on this.
PROBLEM: I could ssh into my target prod server, and from there ssh into my repo server (for git) fine. When I run “cap deploy:update” it seems when the capistrano scripts running on my target prod server get a “failed password” when trying to access the repo server.
After some great help from Jamis Buck (developer of capistrano) the problem became clearer.
ANSWER: Set the following variable in the capistrano “./config/deploy.rb” file.
"default_run_options[:pty] = true"
FURTHER INFO (from Jamis)
By default, Capistrano WILL load ~/.bashrc for each command (since about cap 2.4 or so). However, this default causes problems with interactive processes, like sudo or svn or other processes that may want to prompt for input. Thus, it is common for people to tell Capistrano to request a pty from the server, via default_run_options[:pty] = true. However, when cap requests a pty, the shell will not load the user's profile script. There's no good solution for this, except to NOT rely on your .bashrc (or similar) script. What kinds of things are you expecting to be set that way? You can mimic a pty-less SSH session like this: ssh -T host.com "git clone -q /repos/equity/.git /tmp/test" Likewise, you can mimic SSH session with pty-allocation like this: ssh -t host.com "git clone -q /repos/equity/.git /tmp/test" (pty-allocation is the default for openssh, but the difference there is that ssh requests an interactive user shell, and capistrano does not.)
