Use different keys for Git and SSH

We needed to run a capistrano recipe on a remote box so it would deploy
the code on another remote box. Here is a simple schematic diagram!

Our dev box Our server Destination Server

This works if your git repository shares the same key with your server.
In our case it wasn’t. We have one key to connect to the Destination
Server and another one used for the git repository.

Here is a workaround for this scenario:

Write your normal cap deploy file, configured with the SSH key used for
connecting to the Destination Server. That would look like this:

ssh_options[:keys] = '/keys/my_ssh_key.pub'

When it’s time to run the cap deploy on Our Server against Destination
Server, we did this to make it work:

ssh-agent bash -c 'ssh-add /keys/git_key.pub; cap deploy'

Khash Sajadi

Khash is the founder and CEO of Cloud 66, a full stack container management as a service. Follow him on @khash

London, UK and San Francisco, US
Subscribe and get updates

Have feedback? Please get in touch @cloud66 on Twitter.

Everything you need to build, manage and maintain containers in production on your own servers and any cloud

Try Cloud 66 — 14 Days Free Trial, No credit card required