How do you write a drush alias for a local Vagrant box? I'm trying to write a simple drush alias to connect to a Drupal site running on a local Vagrant instance.

I have the following in a file called ~/.drush/l.aliases.drushrc.php:

$aliases['o'] = array(
  'parent' =&gt; 'l',
  'root' =&gt; '/vagrant/docroot',
  'remote-host' =&gt; '127.0.0.1',
  'remote-user' =&gt; 'vagrant',
  'ssh-options' =&gt; '-p 2222 -i ~/.vagrant.d/insecure_private_key',
  'uri' =&gt; '127.0.0.1:8080',
);


The alias is found. drush sa returns:

l
l.o


However, when I drush @l.o status it doesn't connect to the remote host:

PHP executable        :  /usr/local/bin/php
PHP configuration     :  /usr/local/etc/php/5.3/php.ini
PHP OS                :  Darwin
Drush version         :  6.1.0
Drush configuration   :


I have confirmed that this command successfully connects to vagrant:

ssh vagrant@127.0.0.1 -p 2222 -i ~/.vagrant.d/insecure_private_key


Debugging output doesn't show an SSH command so far as I can tell:

SIG-106:ilob justin$ drush --debug @l.o status
Bootstrap to phase 0. [0 sec, 3.78 MB]                               [bootstrap]
Drush bootstrap phase : _drush_bootstrap_drush() [0.01 sec, 3.98 MB] [bootstrap]
Loaded alias @l.o from file /Users/justin/.drush/l.aliases.drushrc.php [0.01 sec, 3.99 MB]                                                                        [notice]
Cache MISS cid: 6.1.0-commandfiles-0-807b6772846e18b2741e8d5b7119b4cc [0.01 sec, 4 MB]                                                                             [debug]
Cache SET cid: 6.1.0-commandfiles-0-807b6772846e18b2741e8d5b7119b4cc [0.01 sec, 4.02 MB]                                                                           [debug]
Bootstrap to phase 0. [0.05 sec, 9.56 MB]                                                                                                                      [bootstrap]
Found command: core-status (commandfile=core) [0.08 sec, 9.56 MB]                                                                                              [bootstrap]
Loading outputformat engine. [0.13 sec, 9.6 MB]                                                                                                                   [notice]
Calling hook drush_core_status [0.14 sec, 9.65 MB]                                                                                                                 [debug]
Returned from hook drush_core_status [0.14 sec, 9.66 MB]


I know I must be doing something stupid but I just can't see it.
I was able to use drush alias with following configuration:

Let's assume two things:


vagrant box has some sort of static ip (can be private, for example: 192.168.56.101)
IP of vagrant is available in symbolic form (for example, we have single line in /etc/hosts with ip and hostname). (for example: test.site.local).


Step 1:
We need to copy settings, generated by vagrant ssh-config command into $HOME/.ssh/config

Host test.site.local
    IdentitiesOnly yes
    UserKnownHostsFile /dev/null
    StrictHostKeyChecking no
    PasswordAuthentication no
    IdentityFile [path to vagrant private insecure key]


Step 2:
With such configuration, my alias was in following form:

$aliases['example'] = array(
   'root' =&gt; '/var/www',
   'uri' =&gt; 'test.site.local',
   'remote-host' =&gt; 'test.site.local',
   'remote-user' =&gt; 'vagrant',
   'ssh-options' =&gt; "-i path_to_insecure_private_key"
);