# Configuring Drush site aliases for Drupal

> Set up Drush site aliases and SSH keys so you can run Drush commands on your hosted Drupal site from your own computer.

Source: https://helpcenter.ruachost.com/apps/drupal/configuring-drush-site-aliases-for-drupal/

**Drush site aliases** allow you to run Drush commands on remote Drupal sites directly from your local computer. This makes it easier to manage multiple sites, automate updates, and streamline administration. On **ruachost.com**, you can configure site aliases to securely connect to your hosted Drupal installations.

## Why Use Site Aliases?

- Run Drush commands locally that execute on remote servers.
- Automate updates across multiple Drupal sites.
- Simplify workflows by avoiding repeated SSH logins.
- Improve efficiency for developers and administrators.

## Steps to Configure Drush Site Aliases

### Step 1: Create Alias File

1. On your local computer, navigate to your home directory:

   - Linux → `/home/username`
   - macOS → `/Users/username`
   - Windows → `\Users\username`
2. Open the `.drush` subdirectory (create it if it doesn’t exist).
3. Create a file named:

   ```
   sitename.aliases.drushrc.php
   ```

   *(Replace* `sitename` *with a descriptive name for your site.)*

### Step 2: Add Configuration

Paste the following sample configuration into the file, replacing values with your own:

```
<?php
$aliases['sitename'] = array(
  'root' => '/home/username/public_html',
  'remote-host' => 'example.com',
  'remote-user' => 'username',
  'ssh-options' => '-p 7822',
);
?>
```

- **root** → Path to your Drupal installation.
- **remote-host** → Your site’s domain name.
- **remote-user** → Your hosting account username.
- **ssh-options** → Port number (Ruachost uses port 7822 by default).

### Step 3: Set Up SSH Keys

- Drush does not allow storing SSH passwords in alias files.
- To avoid typing your password every time, configure **SSH keys** for your Ruachost account.
- See Ruachost documentation on setting up SSH keys.

### Step 4: Use the Alias

Run Drush commands by prefixing with `@sitename`. Examples:

```bash
drush @sitename status
drush @sitename up
```

- `status` → Displays site information.
- `up` → Updates the site.
- Any Drush command can be run using the alias.

## Important Notes

- Always back up your site before running update commands.
- Use descriptive alias names if managing multiple sites.
- If your hosting account uses a different SSH port, update the `ssh-options` setting.
