This article shows how you can encrypt and decrypt Magento configuration settings values using the n98-magerun2 command line (CLI) tool.
Get configuration settings value in plain text
n98-magerun2.phar config:store:get path/of/config/setting
Get configuration settings value on store level
n98-magerun2.phar config:store:get --scope=stores --scope-id=2 config/setting/path
Get decrypted configuration settings value
n98-magerun2.phar config:store:get --decrypt config/setting/path
Set configuration settings value in plain text
n98-magerun2.phar config:store:set config/setting/path your_custom_value
Set encrypted configuration settings value
n98-magerun2.phar config:store:set --encrypt payment/webpay/keyid NEW_KEY_ID_VALUE_HERE
Config Get Manual
n98-magerun2.phar config:store:get --help
Description:
Get a store config item
Usage:
config:store:get [options] [--] [<path>]
Arguments:
path The config path
Options:
--scope=SCOPE The config value's scope (default, websites, stores)
--scope-id=SCOPE-ID The config value's scope ID or scope code.
--decrypt Decrypt the config value using env.php's crypt key
--update-script Output as update script lines
--magerun-script Output for usage with config:store:set
--format=FORMAT Output Format. One of [csv,json,json_array,yaml,xml]
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--root-dir[=ROOT-DIR] Force magento root dir. No auto detection
--skip-config Do not load any custom config.
--skip-root-check Do not check if n98-magerun runs as root
--skip-core-commands Do not include Magento 2 core commands
--skip-magento-compatibility-check Do not check for Magento version compatibility
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
If path is not set, all available config items will be listed. path may contain wildcards (*)
Config Set Manual
n98-magerun2.phar config:store:set --help
Description:
Set a store config item
Usage:
config:store:set [options] [--] <path> <value>
Arguments:
path The store config path like "general/local/code"
value The config value
Options:
--scope[=SCOPE] The config value's scope (default, websites, stores) [default: "default"]
--scope-id[=SCOPE-ID] The config value's scope ID [default: "0"]
--encrypt The config value should be encrypted using env.php's crypt key
--no-null Do not treat value NULL as NULL (NULL/"unknown" value) value
-h, --help Display this help message
-q, --quiet Do not output any message
-V, --version Display this application version
--ansi Force ANSI output
--no-ansi Disable ANSI output
-n, --no-interaction Do not ask any interactive question
--root-dir[=ROOT-DIR] Force magento root dir. No auto detection
--skip-config Do not load any custom config.
--skip-root-check Do not check if n98-magerun runs as root
--skip-core-commands Do not include Magento 2 core commands
--skip-magento-compatibility-check Do not check for Magento version compatibility
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
Help:
Set a store config value by path.
To set a value of a specify store view you must set the "scope" and "scope-id" option.
Hope this helps. Thanks.