Modern Agility


Configuring Deprec to use SSH-Agent Forwarding

Posted by Kenny Johnston on 05/21/2010

If you’re using a Git repository for your Rails application and Capistrano/Deprec for deployments, you’ll probably want to enable SSH-Agent Forwarding so that the server you’re deploying code to can clone the repository from the server that hosts it by proxying your locally-stored SSH key. So let’s do that:

Assuming SSH-Agent is running and you have your public and private keys (usually something like ‘id_rsa.pub’ and ‘id_rsa’) stored in ~/.ssh, you can easily add this key to ssh-agent:

ssh-add -K /Users/username/.ssh/name_of_your_private_key

The -K option will add the key to your Keychain.

Then, you’ll want to add the following line to your deploy.rb file to indicate that you’d like to use the forward agent:

set :ssh_options, { :forward_agent => true }

Before you deploy, you’ll want to SSH into the server you’ll be deploying to and from it SSH into, or perhaps execute a git clone command, to connect to the server your repository is hosted on so that you can accept the RSA key fingerprint that you’ll be prompted to accept before this will work.

Tags: rails, git, capistrano, deprec, ssh, osx



Leave a Comment