Skip to content

Tightening WHM session timeout and security without locking out your own scripts

WHM session security defaults are permissive. A short list of the toggles that matter — session timeout, IP locking, 2FA — without breaking the automations that share an IP.

A WHM session left logged in on a laptop for a week is one stolen device away from a major incident. The session-security toggles in WHM are not enabled by default — session timeout is generous, IP locking is off, and two-factor is opt-in per user. Tightening these without breaking the scripts that share an outbound IP with your admin laptop takes ten minutes and a checklist.

What’s happening

WHM session state lives in /var/cpanel/sessions/raw/. The default session timeout is two hours of inactivity; the default behaviour on IP change is to invalidate the session (this can be relaxed for users behind dynamic NAT, which is why some teams turn it off entirely). The 2FA implementation is TOTP-based, enabled per WHM user. The Security Advisor flags missing 2FA on root but does not enforce it. Each toggle has a single Tweak Setting or per-user knob.

How to verify

Audit the current state of session security on the server:

whmapi1 get_tweaksetting key=session_timeout
whmapi1 get_tweaksetting key=cookieipvalidation
whmapi1 has_two_factor_auth_enabled user=root
ls /var/cpanel/sessions/raw/
tail -f /usr/local/cpanel/logs/login_log

The cookieipvalidation setting controls whether a session is invalidated on source IP change. The session_timeout value is in seconds. The login log records every WHM login attempt by user and source IP.

The fix

  1. Cut the session timeout to 30 minutes for interactive users: whmapi1 set_tweaksetting key=session_timeout value=1800. Two hours is too long for any production admin tool.
  2. Enable cookie IP validation unless your admins truly need session continuity across IPs: whmapi1 set_tweaksetting key=cookieipvalidation value=loose. The loose value tolerates IP changes within the same /16 (typical NAT shifts); the strict value pins to the exact IP.
  3. Enforce 2FA for root and reseller users. There’s no single switch — each user enrols via WHM > Manage Users > Two-Factor Authentication. For the root user specifically, set up TOTP and store the recovery codes in your secret vault. The recovery codes are the only way back if the TOTP device is lost.
  4. For automation that needs to keep working under cookie IP validation, switch from session-based auth to API tokens. Tokens are not subject to session timeout or IP validation; they’re subject to their own ACL and the optional --allow_from source-IP restriction.
  5. Restrict WHM source IPs at the firewall to known operator and automation egress IPs. The session controls are a defence-in-depth layer; the actual security boundary is the firewall.

For shops with WHM exposed to the public internet, Stack Harbor’s cPanel server management practice wraps the session controls with a WireGuard or Tailscale bastion so WHM is never reachable from anywhere except trusted egress IPs.