2

Capistrano keeps asking me for password for every deplyoyment. How do I not let it happen?

ruby version 1.8.7 REE

capistrano version 2.5.19

Here is my capfile and directory permissions.

http://pastie.org/1189919

Everything up-to-date
 ** transaction: start
  * executing `deploy:update_code'
    updating the cached checkout on all servers
    executing locally: "git ls-remote g...@github.com:username/
app_name.git master"
  * executing "if [ -d /var/www/app_name/shared/cached-copy ]; then
cd /var/www/app_name/shared/cached-copy && git fetch -q origin && git
reset -q --hard 5d47453e28385200daa971ca4982632caf7fb67e && git clean -
q -d -x -f; else git clone -q g...@github.com:username/app_name.git /
var/www/app_name/shared/cached-copy && cd /var/www/app_name/shared/
cached-copy && git checkout -q -b deploy
5d47453e28385200daa971ca4982632caf7fb67e; fi"
    servers: ["1xx.2xx.xxx.xxx"]
Password:
    [173.230.158.13] executing command
    command finished

Update

OK, i am in a super bad mess, now I get this error.

http://pastie.org/1190332

I added a "deploy" user like..

adduser --system --home /home/deploy --shell /bin/bash --ingroup nogroup deploy
chmod u+w /etc/sudoers
echo "deploy  ALL=(ALL) NOPASSWD: ALL" >> /etc/sudoers
chmod u-w /etc/sudoers

Then I added the configuration you mentioned in my .ssh/config file.

Host prod
  Hostname xxx.xxx.xxx.xx
  User deploy
  ForwardAgent yes

Please help!

badnaam
  • 1,876
  • 4
  • 29
  • 53
  • Your new error is because your new user 'deploy' probably doesn't have access to the files you're trying to update from git. Just rename the user in your .ssh/config file back to the original one you were connecting with... – Andrew Vit Sep 30 '10 at 04:44

2 Answers2

3

Github is probably asking for your password because it's not getting your ssh key when connecting from your server. Set up agent forwarding in your ~/.ssh/config:

Host my_deploy_server
  Hostname 1.2.3.4
  User deploy
  ForwardAgent yes

Host *
  ForwardAgent no
Andrew Vit
  • 18,961
  • 6
  • 77
  • 84
  • my deploy_server in this case is my desktop where I am deploying from? – badnaam Sep 29 '10 at 23:24
  • No, this is a convenience name for the server you're deploying to: name it whatever you like. This also lets you do `ssh myserver` instead of having to spell out `ssh deploy@myserver.example.com` – Andrew Vit Sep 29 '10 at 23:37
  • 1
    Don't you also need `ssh_options[:forward_agent] = true` in the deploy script? or is that for something else? – zetetic Sep 30 '10 at 01:21
  • and what is the Hostname 1.2.3.4? – badnaam Sep 30 '10 at 01:27
  • OK, i am in a super bad mess, now I get this error. I added a "deploy" user like.. – badnaam Sep 30 '10 at 01:32
  • The Hostname and User are just the address & username you use to connect to your server. Hostname can be IP address or domain name. – Andrew Vit Sep 30 '10 at 04:41
  • zetetic is right, you can use `ssh_options[:forward_agent]` in your deploy script as well, but that only sets it for capistrano, not when you connect directly using ssh. – Andrew Vit Sep 30 '10 at 04:43
1

It's probably the password for your server. Try setting shared keys between the machine you are deploying from and the destination servers.

Chris Gutierrez
  • 4,750
  • 19
  • 18