Information for: DEVELOPERS   PARTNERS

Using Drush aliases

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

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

Your environments may 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 Cloud Platform 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 Cloud Platform without having to copy the private key to the Cloud Platform 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 using 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 Cloud Platform using your email address and Acquia password.

  2. Click your user avatar in the upper-right corner, and then click Account Settings.

    Account settings

  3. On the Profile page, click Credentials.

    Profile Credentials page

  4. In the Confirm your current password field, enter your current password and then click Confirm.

  5. Complete the following steps by selecting the tab corresponding to your current version of Drush:

    1. Under Drush integration, click Download Drush 8 aliases.

    2. Extract the downloaded archive file into $HOME:

      $ tar -C $HOME -xf $HOME/Downloads/cloud-platform.drush-8-aliases.tar.gz
      
    1. Under Drush integration, click the link for downloading Drush 9 aliases.
    2. Follow the instructions within the README file.

Use the aliases on your local command line as though you’re signed in to your Cloud Platform 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. You can resolve the issue by doing either of the following:

Important

Don’t add files from your .drush aliases directory to your Cloud Platform server’s home directory. The Drush alias files include a remote-host setting that enables them to function from your local computer, but which can prevent SSH connections if it’s present on your Cloud Platform 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. Ensure you examine your alias file to check whether 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 a Cloud Platform server with SSH forwarding, you can access all your environments without copying your private key to Cloud Platform. To view the Drush status for your production website while you’re signed in to the server for your staging environment, enter the following commands, replacing server names as appropriate:

ssh -A [email protected] drush @example.prod status

Refreshing Drush aliases

From time to time, your Drush aliases may change if your server infrastructure (and hostname of your Cloud Platform) was changed. For example, your Drush aliases may change if you relaunch or resize your server instance. The aliases may also change if you upgrade your subscription from Cloud Platform Free to Cloud Platform Professional, or from Cloud Platform Professional to Cloud Platform Enterprise.

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

drush acquia-update