The WordPress admin dashboard, though intuitive and feature-rich, can be time-consuming to explore. If you’re looking for a more direct approach to website management, consider giving the WordPress Command Line Interface (WP-CLI) a try!
WP-CLI is an efficient and powerful way to manage your WordPress installation, allowing you to update your core files and plugins, configure multisite installations, and even backup your WordPress website. The official WP-CLI tool enables you to interact directly with your WordPress environment via text commands to a Secure Shell (SSH) window connected to your website’s server.
In this post, we’ll be going over the basics of how to connect to your WordPress website via SSH and WP-CLI.
What you will need to connect via WP-CLI:
There are a number of minimum requirements you’ll need to meet in order to install WP-CLI:
- SSH login credentials
- Unix environment or SSH client
- WordPress 3.7 or later
- PHP 5.6 or later
SSH access
To access your website over SSH you will first need to obtain your server and login credentials. This is not the same as your WordPress Dashboard (wp-admin) login; you can usually find this information by logging into your hosting company’s website or by contacting their support team.
Log in to your hosting company’s website and look for options related to SSH or Shell Access. Enable it and take note of your server and login information, which is typically in the following format:
- Server: server.name.com
- User: username
- Password: ***************
In most cases, your server will be your website domain name (ie. example.com). You can try searching for “SSH” in your host’s knowledge base. Depending on your host’s setup, you may need to generate a key pair, and they can guide you through that process.
Note: Not all hosting providers will provide their clients with SSH access to their servers.
Connecting to SSH
Mac and Linux
If you’re a Mac or Linux user, there’s no need to install an SSH client. Simply use your built-in terminal application and follow these steps to connect to your website with your new SSH credentials:
- Open Terminal (built-in)
- Type this, replacing the username and server.name.com with your own user and server:
ssh username@server.name.com
- Enter your password.
- When you are connected successfully, you won’t receive an error or a confirmation, just a prompt where you can start typing. You will now be at the root of your website!
You can check that you are in the root of your website by typing:
ls
This command will list the contents of the folder you are in. You should see your WordPress files in those folders (wp-admin, wp-content, wp-includes, etc).
Windows
If you’re a Windows user, you’ll need to download an SSH client. I’ve included instructions for PuTTy below:
- Download the PuTTy executable from the official website.
- Install the executable on your environment.
- Open the application.
- Enter your server in the Host Name and select SSH from the radial button.
- Click Open.
- Enter your SSH username and password.
Upon successful connection, you’ll see a prompt where you can input commands. You can check to see if you are in the root of your website by typing:
ls
This command will list the contents of the folder you are in. You should see your WordPress files in those folders (wp-admin, wp-content, wp-includes, etc).
Installing WP-CLI
Once you have successfully connected to your server via SSH, copy and paste the following commands to download and install WP-CLI:
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Alternatively, you can use:
wget https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar
Download progress will be displayed. You know it’s working when you get a fresh prompt and no error messages.
To verify the installation, type:
wp cli version
You should see the version number displayed.
Note: A number of hosting providers already have WP-CLI installed by default. If your website is hosted by any of the hosting providers in this list then you may be able to skip this step!
Video Tutorial
You can refer to this quick video tutorial to assist you with connecting to your website with WP-CLI. Enjoy!
What can I do with WP-CLI?
WP-CLI makes it super easy to access and manage your website from the comfort of your command line. These are literally dozens of commands you can leverage to manage your WordPress installation.
Some great use cases include:
Be sure to check out the official WP-CLI Commands and official documentation. It’s a handy resource for any WordPress admin!