Using capistrano with SSH-agent

I develop on my laptop, and deploy to an application server which I connect to via SSH. The laptop and the application server both talk to my subversion repository using urls like "svn+ssh://my.svn.server/repository/project/...", which is on a different server. For security and simplicity, my private key is only stored on my laptop. Only my public SSH key is on the application server.

When I fire up the laptop, I also setup an ssh-agent to which I authenticate using my private key, then I use agent forwarding so that I can ssh to all my servers without re-typing my passphrase, and so that I can checkout code from subversion while I am logged into the application server.

Capistrano uses Net::SSH to provide SSH connectivity. Unfortunately, Net::SSH completely ignores your .ssh/config file, so you have to specify all your servers via resolvable names or IP numbers. In other words, if you have an application server that you refer to as 'wibble' in your .ssh/config, and which points to IP number, that won't help capistrano deploy your application.

So, in your config/deploy.rb you will either need to have something like this;

    set :app, "" 
...which is really ugly. Or, you need to put something in your /etc/hosts file that gives you a nicer name that resolves to that IP number. e.g.; wibble.mydev.pri
...and then in your config/deploy.rb
    set :app, "wibble.mydev.pri"
Most importantly, you need to have this line in your config/deploy.rb
    set :ssh_options, { :forward_agent => true }
Happy Capping!