Configure MFA Secret Using CLI
To use Multi-Factor Authentication (MFA) with the Contentstack CLI, you must first set up or remove your MFA secret. This guide walks you through how to configure your MFA settings using CLI commands.
Prerequisites
- Contentstack account
- CLI installed
- MFA enabled
- A copy of MFA secret
Set the MFA Secret
The CLI reads the MFA secret from the CONTENTSTACK_MFA_SECRET environment variable. Set it in the shell session that runs the CLI, then log in as usual. The CLI generates the one-time password from it automatically.
macOS and Linux
export CONTENTSTACK_MFA_SECRET="<your-mfa-secret>" csdx auth:login
Windows PowerShell
$env:CONTENTSTACK_MFA_SECRET = "<your-mfa-secret>" csdx auth:login
Warning The config:mfa:add and config:mfa:remove commands no longer exist. Scripts that call either one fail with a command-not-found error. Replace them by setting or unsetting CONTENTSTACK_MFA_SECRET.
Remove the MFA Secret
Unset the environment variable. There is no CLI command for this.
unset CONTENTSTACK_MFA_SECRET
Note Because the secret now lives in the environment rather than the CLI config file, treat it like any other credential. Avoid committing it to source control, and prefer your CI provider's secret store over a plain environment variable in a pipeline definition.