I'm setting up Capifony (Capistrano for symfony) but I've an issue with ssh password when testing multiple server deploy.
Here some versions:
daniel@fiji:~$ ruby --version
ruby 1.8.7 (2011-06-30 patchlevel 352) [i686-linux]
daniel@fiji:~$ cap --version
Capistrano v2.9.0
daniel@fiji:~$ uname -a
Linux fiji 3.0.0-13-generic-pae #22-Ubuntu SMP Wed Nov 2 15:17:35 UTC 2011 i686 i686 i386 GNU/Linux
And some configurations from deploy.rb:
set :domain, "mydomain"
...
set :user, "sshuser"
set :password, "sshpassword"
...
role :web, domain
role :app, domain
...
Deploying to a single server works great, no need to enter passwords. All fine. But if I try to add more servers to the configuration (I'll need to deploy to 6 to 9 machines) with a configuration like this:
...
set :user, "sshuser"
set :password, "sshpassword"
role :web, "ipaddr1", "ipaddr2"
role :app, "ipaddr1", "ipaddr2"
...
Capistrano starts to ask me ssh password for each server listed even if it's set as before...what's wrong with this configuration? Entering the password lets the process continue and all works, but I'd like to avoid to enter the password every time.
Thanks Daniel
I don't see why capistrano keeps asking for your password. However, one way to solve this issue is to use public key authentication, which is suggested in the capistrano wiki as well. (see this tutorial for an example of how to set this up)
In short:
ssh-keygen -t rsa -C "youremail"
scp -p .ssh/id_rsa.pub remoteuser@remotehost:
cat id_rsa.pub >> ~/.ssh/authorized_keys
. (You might need to create the .ssh dir)After that you should only need to enter your password once and you won't need to have your password hardcoded in your deploy.rb file.
According to more experienced users I can say that using password for ssh authentication is not a good practice. Far better using ssh keys and rely on them. Just need to remove the row
and obviously set up public keys on every server where to deploy.