Kevin Warrington

Loading clever subtitle...

Executing Drush Commands Outside of Vagrant Using Aliases

Drush aliases make it possible to run commands from outside your vagrant box, and even outside of your project directory.

To start, you need a ~/.drush/dev.aliases.drushrc.php file:

1
2
3
4
5
6
7
8
9
10
$aliases['project1'] = array(
  'root' => '/vagrant',
  'remote-host' => '10.0.0.124',
  'remote-user' => 'vagrant',
);
$aliases['project2'] = array(
  'root' => '/vagrant',
  'remote-host' => '10.0.0.125',
  'remote-user' => 'vagrant',
);

Next, you need to copy your public key to your vagrant box, the password is vagrant:

1
ssh-copy-id -i ~/.ssh/id_rsa.pub vagrant@10.0.0.124

And finally, test the connection:

1
drush @project1 status

Drush will use your alias configuration to select the appropriate root directory and remote host. You should be able to run the above command from any directory.

Comments