> ## Documentation Index
> Fetch the complete documentation index at: https://kb.hosting.com/llms.txt
> Use this file to discover all available pages before exploring further.

# How to use SSH and WP-CLI from the command line on hosting.com Managed WordPress

> Learn how to use SSH to run the WP-CLI tool from the command line directly on hosting.com Managed WordPress.

If you have never used the command-line interface or WP-CLI before, this guide is for you.

WP-CLI is a powerful way to manage Wordpress and plugins. From the command-line interface, there is no such thing as a timeout, and you can import long files, clear the cache, back up your website and a lot more!

<Tip>
  * Before you use WP-CLI, please read the release announcement at the [Rocket.net blog](https://rocket.net/blog/introducing-web-based-wp-cli-terminal-for-managed-wordpress-hosting/) for an overview and some basic information about how to use it.
  * You can also run WP-CLI directly from the hosting.com Dashboard without having to set up SSH. For information about how to do this, go to [Using WP-CLI in the hosting.com Dashboard](/docs/using-wp-cli-in-the-hostingcom-dashboard).
</Tip>

## Step 1: Generate an SSH key pair

To access WP-CLI from the command line, you must first create an SSH key pair for your account. To do this, follow these steps:

1. Open your system’s terminal or command-line tool:
   * Microsoft Windows: Use **Command Prompt** or **PowerShell**.
   * Apple macOS and Linux: Use **Terminal**.
2. At the command prompt, type the following command:
   ```text theme={null}
   ssh-keygen -t rsa
   ```
3. When you are prompted:<br />i. Press **Enter** to accept the default location (usually *\~/.ssh/id\_rsa* or similar).<br />ii. Leave the passphrase empty.
4. After the key pair is generated, to view and copy your **public key** type the following command:
   ```text theme={null}
   more .ssh/id_rsa.pub
   ```
   You will need the public key in the next procedure.

## Step 2: Add the public key in the hosting.com Dashboard

To add your public key in the hosting.com Dashboard, follow these steps:

1. Log in to the Hosting Panel at [https://my.hosting.com](https://my.hosting.com).
2. In the left sidebar, click **Managed WordPress**:
   ![](https://files.readme.io/6f570e0ca5d448c0cc2e1bd0fc2fabad74a0c1c5367ea425e652a938e8d5053d-image.png)
3. On the **My Websites** page, locate the site for which you want to enable SSH, and then click **Manage**:
   ![](https://files.readme.io/6fe1aa300f93cf0bc299f70bf22337e249a3fe6fa2ae47ddc7455c52eec45fcb-image.png)
4. On the hosting.com dashboard, click the **Advanced** icon:
   ![](https://files.readme.io/8be7350c767b91b4b19c180f3ef434975de17d6d53cb409653a78e62c98cac26-image.png)
5. In the **Advanced Settings** section, click the **SSH Access** slider if it is not already enabled:
   ![](https://files.readme.io/88cdd4ee64c075accfe94c9997d429e7cf0b3d796daba63b86364228aca424d1-image.png)
6. Scroll down to the **SSH Keys** section, and then click **Import New Key**:
   ![](https://files.readme.io/67832b661cc241f5eb1961966909bc256f6ef3b6189d5e723da0cfba26e99877-image.png)
7. In the **Import New Key** dialog box, in the **Key Name** text box, type a descriptive name for the key:
   ![](https://files.readme.io/6f0669e006c724c0951eb85fb83da8155b7b46d1d365757d5e39a22fded1ebd0-image.png)
8. In the **Key Passphrase** text box, type the passphrase for the key. If you did not create a key passphrase when you generated the key, then leave the **Key Passphrase** text box blank.
9. In the **Key** text box, paste the public key.
10. Click **Import**.
11. After you import the key, authorize it by clicking the three-dots menu next to the key and selecting **Authorize**.

## Step 3: Connect to the server and run WP-CLI

You're ready to connect to the server and run WP-CLI. To do this, you need your SSH username and server IP address.

<Tip>
  You can find the SSH username and server IP address on the **General** tab in the **Site Information** section, just above the **FTP Accounts** section:

  ![](https://files.readme.io/bbd248c1f140ac45b6c6457485557861559a872fa72cab0f0fcca6228f23a004-image.png)
</Tip>

When you have the username and IP address, go back to your terminal and then type the following command. Replace *sshusername* and *IPaddress* with the correct values for your account:

```text theme={null}
ssh sshusername@IPaddress
```

<Note>
  If this is the first time you are connecting to your account, you may receive a warning message. Type `y` and press Enter.
</Note>

You are now at the command prompt. Type the following command to go to the *public\_html* directory:

```text theme={null}
cd public_html
```

You can now run WP-CLI commands. For example, you can purge the cache:

```text theme={null}
wp cache flush
```

You can purge the CDN cache:

```text theme={null}
wp cdn purge
```

You can view your current domain:

```text theme={null}
wp option get home
```

<Tip>
  For more information about WP-CLI and its various commands, go to the [WP CLI documentation](https://developer.wordpress.org/cli/commands/).
</Tip>
