iThemes Security WP-CLI Integration

iThemes Security Pro now has WP-CLI integration! The goal is for anything you can do via the WordPress Admin to be something you can do with WP-CLI as well.

WP-CLI Reference - http://wp-cli.org/

Run the commands in command line while in your WordPress installation.

wp itsec browser <user-agent> [--fields=<fields>] [--format=<format>]
wp itsec dashboard <command>
wp itsec events <command>
wp itsec feature-flag <command>
wp itsec file-change <command>
wp itsec geo <command>
wp itsec import-export <command>
wp itsec lockout <command>
wp itsec log <command>
wp itsec map <command>
wp itsec modules <command>
wp itsec nc <command>
wp itsec network-brute-force <command>
wp itsec scaffold-entry <module> <name>
wp itsec schema
wp itsec security-check [--format=<format>]
wp itsec settings <command>
wp itsec two-factor <command>
wp itsec upgrade [--build=<build>]
wp itsec user-group <command>

To view documentation about any particular command, use the built in `help` command. For example.

$ wp help itsec log

NAME

wp itsec log

SYNOPSIS

wp itsec log <command>

SUBCOMMANDS

get Get a log item.
list List log items.
prune Prune log items.

Lockouts

You can use WP CLI to view the recent lockouts.

$ wp itsec lockout list --limit=5 --type=host --fields=id,type,start_gmt,host
+-------+-------------+---------------------+----------------+
| id | type | start_gmt | host |
+-------+-------------+---------------------+----------------+
| 26245 | brute_force | 2020-03-11 15:27:41 | 203.205.54.247 |
| 26244 | brute_force | 2020-03-11 15:27:08 | 45.224.105.91 |
| 26242 | brute_force | 2020-03-11 14:31:19 | 185.220.101.70 |
| 26240 | brute_force | 2020-03-11 11:16:17 | 88.249.66.157 |
| 26238 | brute_force | 2020-03-11 06:01:18 | 45.154.255.44 |
+-------+-------------+---------------------+----------------+

Then, you can use the id to release a lockout.

$ wp itsec lockout release 26245
Success: Released lockout 26245.

Managing Modules and Settings

iThemes Security supports enabling/disabling modules as well as editing a module's settings via WP CLI.

$ wp itsec modules enable recaptcha
Success: Module activated.

$ wp itsec settings set recaptcha type v3
Success: Setting updated.

If you want to edit multiple settings at once interactively, use the edit command to launch the built-in editor. Saving in your editor will persist your changes.

$ wp itsec settings edit recaptcha

Two-Factor

You can use WP CLI to manage the Two-Factor methods available to a user. For instance, to enable the Mobile App method for a user, run the following command.

$ wp itsec two-factor user method enable 1 Two_Factor_Totp
Totp Secret: PFDUEMRJFYQCKM3YGVFEYJKEJIQSS4LS
Success: Enabled Two_Factor_Totp method.

Or to generate a new list of backup codes for a user.

$ wp itsec two-factor user method configure 1 Two_Factor_Backup_Codes
Backup Codes: 32248965 77755697 87038658 08505644 40530877 60233579 06407376 06704530 96288475 96783818

 

Powered by Zendesk