We have been using Capistrano to automate the deployment of our Rails apps. Capistrano is very powerful helps to execute any command on the remote machines. It has before/after callback hooks that helps to execute commands your application might depend on before running cap deploy.

Capistrano assumes all the remote machines have the same credentials. Imagine you want to run commands on different remote machines each having different credentials.

Added a small extension for capistrano to prompt for password again when connecting to another server.

Drop the code in your Rails.root/lib directory.

You will have to add:

in you recipes to force capistrano to prompt.

Bonus: Create ssh public keys and enjoy password-less deployment.

Next step: fork capistrano to add method for connecting to multiple servers