Using Drush aliases

Acquia Cloud defines Drush aliases for all of your application’s environments. For example, the application named (Acquia Cloud username) example has the following Drush aliases for its Development, Staging, and Production environments:

  • example.dev
  • example.test
  • example.prod

Your environments might not all be on the same server, depending on your account and configuration. Using Drush’s remote command capability, you can use any of the aliases to access any of your applications from your local computer or any Acquia Cloud server. The remote aliases work seamlessly if you have your SSH private key available on the source server. To use your SSH private key from Acquia Cloud without having to copy the private key to the Acquia Cloud server, use SSH key forwarding by using the -A argument to SSH when connecting from your local computer.

For the following examples, the Staging environment is on server staging-1 and your Production environment is on web-1, web-2, and web-3.

Note

If you have more than one subscription that uses the same name, your Drush aliases will use the same namespace and overwrite each other.

Downloading Drush aliases

Use the following method to download your Drush aliases:

  1. Sign in to the Acquia Cloud interface using your email address and Acquia password.

  2. Click your user avatar in the upper right corner, and then click Edit profile.

    Edit your profile

  3. On the Profile page, click Credentials.

    Profile Credentials page

  4. Under Drush integration, click Download Drush aliases

Extract the downloaded archive file into $HOME:

tar -C $HOME -xf $HOME/Downloads/example.tar.gz

Use the aliases on your local command line as though you were signed in to your Acquia Cloud server to view the Drush status. For example:

drush @example.test status

Note

Microsoft Windows users may need to edit their $PATH variable to use Drush properly. Options to resolve this issue include the following:

  • Use Acquia Dev Desktop (which will install and configure Drush with the appropriate $PATH value)
  • Edit the path manually

Important

Do not add files from your .drush aliases directory to your Acquia Cloud server’s home directory. The Drush alias files include a remote-host setting that enables them to function from your local machine, but which can prevent SSH connections if it is present on your Acquia Cloud servers.

Example: Viewing site status with Drush

To view the status of your application on the Production environment from your local computer using Drush, enter the following command:

drush @example.prod status

Note

Depending on the age of your subscription, there are two available formats for remote-host. Be sure to examine your alias file to validate that one of the following correct formats is in use, when needed:

  • [subscriptionname][env].ssh.prod.acquia-sites.com
  • serverrname-nnnn.prod.hosting.acquia.com

Viewing site status using Drush and SSH forwarding

By signing in to an Acquia Cloud server with SSH forwarding, you can access all of your environments without copying your private key to Acquia Cloud. To view the Drush status for your Production website while being signed in to the server for your Staging environment, enter the following commands, replacing server names as appropriate:

ssh -A example.test@staging-1.prod.hosting.acquia.com  drush @example.prod status

Refreshing Drush aliases

From time to time, your Drush aliases may change. This can happen when your server infrastructure (and therefore the hostname of your Acquia Cloud) changes. That might happen if your server instance is resized or relaunched, for example, or if you upgrade your subscription from Acquia Cloud Free to Acquia Cloud Professional, or from Acquia Cloud Professional to Acquia Cloud Enterprise.

You can refresh your Drush aliases by downloading them again, and pasting the new version over the old one. As an alternative, you can use this Drush command:

drush acquia-update

Contact supportStill need assistance? Contact Acquia Support

Acquia: Think Ahead

53 State Street, 10th Floor
Boston, MA 02109
United States
Phone: 888-922-7842

Map: Google Maps
View other locations