Use WP-CLI without SSH access to the server

You can connect your local WordPress install to the live site's database, but be very careful.

Need to use WP-CLI on a WordPress site, but don’t have SSH access to its server? Simply change your local WordPress install’s database credentials to use the remote site’s configuration, such that the local WordPress install is using the remote database. You’re now free to run commands to your heart’s content.

Keep in mind:

  • The remote WordPress site’s database will need to accept public connections, or you’ll need to be able to whitelist your IP address.
  • Your local WordPress install should use the exact same codebase as the remote install.
  • Any filesystem operations will be happening on your local machine, not the remote server. If you install and activate a plugin, the remote WordPress site will then try to run a plugin that doesn’t exist on its server.
  • Bad things can happen. Be very careful, and make sure you have a ready way to clean up your mess.