Skip to content

Two-factor on Roundcube webmail on cPanel

How to add 2FA to Roundcube webmail on a cPanel host — what the plugin does, where it stores secrets, and the operator path for a customer who lost their token.

cPanel’s webmail is Roundcube. cPanel’s account-level 2FA does not extend to webmail logins by default — a customer with 2FA on cPanel can still sign in to webmail with just a password. For accounts that handle sensitive correspondence, this gap matters. The fix is the Roundcube twofactor_gauthenticator plugin or equivalent.

What’s happening

cPanel ships Roundcube as the default webmail at /webmail/. Roundcube has a plugin ecosystem, and twofactor_gauthenticator adds TOTP-based 2FA to webmail logins. It stores per-user secrets in Roundcube’s database. The cPanel-specific gotcha: cPanel manages Roundcube’s installation, so plugins must be installed in a way that survives cPanel upgrades.

How to verify

ls /usr/local/cpanel/base/3rdparty/roundcube/plugins/
grep "plugins" /usr/local/cpanel/base/3rdparty/roundcube/config/config.inc.php
mysql roundcube -e "SHOW TABLES LIKE '%two%'"
ls -la /usr/local/cpanel/base/3rdparty/roundcube/plugins/twofactor_gauthenticator 2>/dev/null

If the plugin directory exists and the database has a users_2fa table (or similar), the plugin is installed and may or may not be loaded.

The fix

  1. Install the plugin: clone the twofactor_gauthenticator plugin into /usr/local/cpanel/base/3rdparty/roundcube/plugins/ (or use composer in the cPanel-shipped Roundcube install).
  2. Enable: edit /usr/local/cpanel/base/3rdparty/roundcube/config/config.inc.php, add 'twofactor_gauthenticator' to the $config['plugins'] array.
  3. Persistence across cPanel upgrades: cPanel may overwrite Roundcube config on upgrade. Document the customization and re-apply post-upgrade, or use cPanel’s hook system to re-add the plugin after each upcp.
  4. Per-user enrollment: each webmail user enables 2FA from Roundcube > Settings > Two-Factor Authentication. They scan the QR with an authenticator app.
  5. Communicate: customers must enroll themselves. Operators cannot enroll on their behalf without seeing the secret, which defeats the purpose.
  6. Recovery for lost tokens: the operator path is to clear the user’s row from the 2FA table: mysql roundcube -e "DELETE FROM users_2fa WHERE user_id = (SELECT user_id FROM users WHERE username = '<user>@<domain>')". Verify customer identity before doing this.
  7. Alternative — disable Roundcube entirely: if 2FA via plugin is too operationally heavy, disable webmail and require customers to use IMAP clients with native 2FA-aware setups (rare in practice, but possible).

Stack Harbor maintains webmail security configurations across managed accounts under managed cPanel operations.