Doug's Blog

Drush Aliases and SSH aliases

Drush is a pretty handy tool. I use it whenever I’m working on a Drupal site. I also make extensive use of SSH aliases. It doesn’t seem to be documented anywhere but I discovered that you can combine both.

If you have a SSH alias that might look something like:

Host example
    Hostname ssh.example.com
    Port 22
    User ssh-user
    IdentityFile ~/.ssh/example-key-file.pem
    ForwardAgent yes

Then you can leverage that in your local drush aliases.drushec.php file with something like:

$aliases['example'] = array(
    'uri' => 'http://www.example.com',
    'remote-host' => 'example',
    'root' => '/path/to/drupal',
);

Basically you can use your ssh alias as the remote-host parameter and it works exactly like you might expect it to.