We are hosting a couple of sites on Acquia Cloud. Up to now I have SSH into the servers when I needed to execute any drush commands, but I want to start using drush on my local dev machine to execute commands on the servers.

Some of the commands work without an problems drush ac-site-list, but as soon as a SSH key is required (for example drush @site.env status I get a Permission denied (publickey). error message. I know this means that the public SSH key being used is not valid, and I also know why this is happening. I have only one SSH key for all the Acquia servers, but because there are different servers for the different sites, and in addition to that I have a couple of 'personal or private' key's; SSH does not know which key to use when I execute Drush.

For other SSH access (SSH in generate to other servers), I use a config file in my .ssh folder with aliases.

The problem is that I do not know how to tell Drush which 'ssh alias' from the .ssh/config file to use.
How can I achieve this?

  • It depends a bit on the structure of the alias file Acquia provides, and it would be helpful if you could update your question with the structure of it. Feb 25, 2016 at 19:24

1 Answer 1


The Drush alias file has an option to provide additional parameters:

'ssh-options': If the target requires special options, such as a non- standard port, alternative identity file, or alternative authentication method, ssh-options can contain a string of extra options that are used with the ssh command, eg "-p 100"

Source: https://github.com/drush-ops/drush/blob/master/examples/example.aliases.drushrc.php

To have SSH use the right SSH key you can append it with ssh -i path/to/key.pem user@server. So in your alias file you should be able to add:

$aliases['alias'] = array(
  'ssh-options' => '-i path/to/key.pem',

I am not sure if you can use the keys defined in .ssh/config, because the config file automatically connects the SSH key with the host. So you'd be able to call ssh user@server and SSH should append the key. Therefore I doubt it can be used as I'd assume drush will automatically use remote-host and remote-user to build the SSH connection: ssh remote-user@remote-host and the keys from .ssh/config shoud be applied at that point.

  • perfect. Added the ssh-options key to each of the alias arrays and it worked. Thanks Mar 10, 2016 at 17:43

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.