How to use SSH and WP-CLI from the command line on Rocket.net Managed WordPress
Learn how to use SSH to run the WP-CLI tool from the command line directly on Rocket.net 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 for an overview and some basic information about how to use it.
- You can also run WP-CLI directly from the Rocket Dashboard without having to set up SSH. For information about how to do this, go to Using WP-CLI in the Rocket Dashboard.
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:
-
Open your systemโs terminal or command-line tool:
- Microsoft Windows: Use Command Prompt or PowerShell.
- Apple macOS and Linux: Use Terminal.
-
At the command prompt, type the following command:
ssh-keygen -t rsa
-
When you are prompted:
i. Press Enter to accept the default location (usually ~/.ssh/id_rsa or similar).
ii. Leave the passphrase empty. -
After the key pair is generated, to view and copy your public key type the following command:
more .ssh/id_rsa.pub
You will need the public key in the next procedure.
Step 2: Add the public key in the Rocket Dashboard
To add your public key in the Rocket Dashboard, follow these steps:
-
Log in to the Hosting Panel at https://my.hosting.com.
-
In the left sidebar, click Managed WordPress:
-
On the My Websites page, locate the site for which you want to enable SSH, and then click Manage:
-
On the Rocket dashboard, click the Advanced icon.
-
In the Advanced Settings section, click the SSH Access slider if it is not already enabled.
-
Click Import New Key.
-
In the Import New Key dialog box, in the Key Name text box, type a descriptive name for the key.
-
Leave the Key Passphrase text box blank.
-
In the Key text box, paste the public key.
-
Click Import.
-
After you import the key, activate the key by clicking the checkmark next to it so it is allowed to access SSH.
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.
You can find the server IP address and SSH username on the General tab in the Site Information section, just above the FTP Accounts section of the Rocket Dashboard.
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:
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.
You are now at the command prompt. Type the following command to go to the public_html directory:
cd public_html
You can now run WP-CLI commands. For example, you can purge the cache:
wp cache flush
You can purge the CDN cache:
wp cdn purge
You can view your current domain:
wp option get home
Tip
For more information about WP-CLI and its various commands, go to the WP CLI documentation.
Updated about 4 hours ago