Install WordPress Plugins via SSH

We show you the 4 simple steps to installing and activating WordPress plugins via SSH below.

For the other ways to install WordPress plugins, see our Install WordPress Plugins post.

Step 1: Connect via SSH

In order to connect to your WordPress site’s server via SSH, a hosting provider may give you an SSH key or a password. You will also be provided with a hostname and an SSH username.

To connect with an SSH key, open up Terminal on a mac or download PuTTY on a PC and open up PuTTY. Then, enter the following command into the command line:

ssh -i "example-ssh-key.pem" ssh_username@hostname.com

To connect with an SSH password, use the following command:

ssh ssh_username@hostname.com

In this second case, you will be prompted to enter in your SSH password. Congrats, you are now connected to your WordPress site’s server!

Step 2: Ensure WP-CLI is Installed on your Server

In order to proceed with installing and activating WordPress plugins via the SSH, you need to ensure that WP-CLI is installed on your server. To do this, navigate to the directory where your WordPress wp-config.php file is (use cd commands) and run the following command in PuTTY or Terminal:

wp help

If WP CLI exists on the server, `wp help` will provide you with information on WP CLI including a list of commands available on your server, that may look like the following:

NAME

  wp

DESCRIPTION

  Manage WordPress through the command-line.

SYNOPSIS

  wp <command>

SUBCOMMANDS

  cache                 Adds, removes, fetches, and flushes the WP Object Cache
                        object.
  cap                   Adds, removes, and lists capabilities of a user role.
  cli                   Review current WP-CLI info, check for updates, or see
                        defined aliases.
  comment               Creates, updates, deletes, and moderates comments.
  config                Generates and reads the wp-config.php file.
  core                  Downloads, installs, updates, and manages a WordPress
                        installation.
cron                  Tests, runs, and deletes WP-Cron events; manages WP-Cron
                        schedules.
  db                    Performs basic database operations using credentials
                        stored in wp-config.php.
  dotenv                Manage a .env file
  embed                 Inspects oEmbed providers, clears embed cache, and more.
  eval                  Executes arbitrary PHP code.
  eval-file             Loads and executes a PHP file.
  export                Exports WordPress content to a WXR file.
  fastly                Define the "fast" WP CLI command.
  help                  Get help on WP-CLI, or on a specific command.
  i18n                  Provides internationalization tools for WordPress
                        projects.
  import                Imports content from a given WXR file.
  language              Installs, activates, and manages language packs.
  maintenance-mode      Activates, deactivates or checks the status of the
                        maintenance mode of a site.
  media                 Imports files as attachments, regenerates thumbnails, or
                        lists registered image sizes.
  menu                  Lists, creates, assigns, and deletes the active theme's
                        navigation menus.
network               Perform network-wide operations.
  option                Retrieves and sets site options, including plugin and
                        WordPress settings.
  package               Lists, installs, and removes WP-CLI packages.
  plugin                Manages plugins, including installs, activations, and
                        updates.
  post                  Manages posts, content, and meta.
  post-type             Retrieves details on the site's registered post types.
  rewrite               Lists or flushes the site's rewrite rules, updates the
                        permalink structure.
  role                  Manages user roles, including creating new roles and
                        resetting to defaults.
  s3-uploads            
  scaffold              Generates code for post types, taxonomies, plugins,
                        child themes, etc.
  search-replace        Searches/replaces strings in the database.
  server                Launches PHP's built-in web server for a specific
                        WordPress installation.
  shell                 Opens an interactive PHP console for running and testing
                        PHP code.
  sidebar               Lists registered sidebars.
  site                  Creates, deletes, empties, moderates, and lists one or
                        more sites on a multisite installation.
super-admin           Lists, adds, or removes super admin users on a multisite
                        installation.
  taxonomy              Retrieves information about registered taxonomies.
  term                  Manages taxonomy terms and term meta, with create,
                        delete, and list commands.
  theme                 Manages themes, including installs, activations, and
                        updates.
  transient             Adds, gets, and deletes entries in the WordPress
                        Transient Cache.
  user                  Manages users, along with their roles, capabilities, and
                        meta.
  widget                Manages widgets, including adding and moving them within
                        sidebars.

As you can see, the list of commands includes any extensions that were added to the base WP CLI package. And, as long as you can see the plugin command in the list above, you’re good to proceed.

Step 3: Install WordPress Plugin

Installing a plugin via SSH with WP CLI is super simple if your plugin exists in the WordPress plugin directory. All you have to do in that case is find the plugin slug associated with the WordPress plugin. The plugin slug is what appears after https://wordpress.org/plugins  in the WordPress plugin directory. Then, run the following command:

wp plugin install plugin-slug

For example, if you would like to install the wpmerchant plugin (a Stripe plugin for WordPress that allows you to add a payment form or payment button to your WordPress site), go to its WordPress plugin directory page and see that it’s at http://wordpress.org/plugins/wpmerchant, so the slug is wpmerchant, and you would simply use the following command:

wp plugin install wpmerchant

You should receive a response in the command line confirming that the plugin was installed.

If the plugin that you wish to install doesn’t exist in the WordPress plugin directory, that’s no problem, you can install a plugin .zip file from any external source. For example, if you built a custom plugin called Crazy Awesome Functionality and the .zip file of that plugin is located at https://blog.wplauncher.com/crazy-awesome-functionality.zip, you would use the following command:

wp plugin install https://blog.wplauncher.com/crazy-awesome-functionality.zip

Step 4: Activate WordPress Plugin

You need to activate a WordPress plugin in order for the functionality of that plugin to actually work on your WordPress site. And, activating a WordPress plugin only works if it has already been installed on your server. Activating a WordPress plugin via SSH with WP CLI is just as easy as the installation process. You simply navigate via the command line to the directory that holds your wp-config.php file and run the following command to activate a plugin:

wp plugin activate plugin-slug

For example, if you would like to activate the wpmerchant plugin on your server, you would run the following WP-CLI command:

wp plugin activate wpmerchant

If you would like to activate the Crazy Awesome Functionality plugin from above you would need to get the plugin’s slug from the actual code of the plugin (typically a file called index.php or plugin-name.php). The plugin slug is usually the plugin name separated by hyphens. Once you have the plugin slug from your custom plugin, you need to run the following command:

wp plugin activate crazy-awesome-functionality

You will receive a message back from the command line saying that the plugin has been activated successfully.

Leave a Reply

Your email address will not be published. Required fields are marked *