Read the original article on

One pitfall I’ve recently encountered with Vagrant and WP-CLI was the lack of an easy way to use my local WP-CLI installation to send a command to my Vagrant box.

X-Team’s Weston Ruter first developed an incredible tool called vassh, which basically removes the pain of having to manually SSH into the Vagrant box and run the command from the project root. While vassh is really useful, it only works for Vagrant and not for remote servers.

After working closely with the WP-CLI team and refactoring multiple times, we finally came up with something called “WP-CLI SSH” which facilitates running WP-CLI commands on other servers, while invoking WP-CLI normally as if it was on your own system.

Here is the workflow before using WP-CLI SSH:

Not very practical and very redundant (not to mention the fact that you need to remember the path and the SSH server name).

With WP-CLI SSH (and WP-CLI >= 0.13) you can automate your workflow with only a few lines of code.

First install WP-CLI SSH with composer:
$ cd ~/.wp-cli && composer require x-team/wp-cli-ssh

Then add one (or many) SSH servers to your wp-cli.local.yml or wp-cli.yml file:

Now you can invoke WP-CLI on your Vagrant machine over SSH simply by:
$ wp ssh plugin status --host=vagrant

To invoke WP-CLI on the staging server (even via an intermediary SSH jump server), you similarly can run:
$ wp ssh plugin status --host=staging

Another very useful trick might be to compare the output of the same command from 2 different servers :
diff <(wp ssh plugin status --host=vagrant) <(wp ssh plugin status --host=staging) -y

Read more about configuring WP-CLI SSH.


An easy way to specify a default server is to create a bash alias for your machine user :
alias wpssh='wp ssh --host=vagrant'