Skip to content

Mass cPanel password rotation — rolling new passwords through the API without lockouts

Rotating a hundred cPanel passwords after a breach is straightforward with the API, but the customer-facing communication and timing matter as much as the rotation itself.

A compromised vendor announces a breach affecting customer credentials. Your shared-hosting customers need their cPanel passwords rotated, and there are 240 of them. The temptation is to run a loop that issues passwd against every account and call it done. The next morning, support is buried in tickets because customers were not told their passwords changed, the new passwords were emailed in clear text, and the FTP clients they had saved with the old credentials are now failing silently.

What’s happening

whmapi1 passwd user=acme password=<new> changes the cPanel password — and propagates it to FTP, MySQL (the cpanel-managed users only), and the mailbox if the customer’s primary email account shares the cPanel password. The change is immediate; existing cPanel sessions for that user are invalidated. The API does not notify the customer, does not log the new password anywhere customer-readable, and does not coordinate the rotation across multiple accounts the same person might own.

How to verify

Plan the rotation by snapshotting the affected accounts and confirming token ACLs:

whmapi1 listaccts --output=json | jq -r '.data.acct[].user' > /tmp/all-accounts.txt
whmapi1 api_token_list_tokens | jq -r '.data.tokens[] | select(.name=="mass-rotate-2026-05") | .acls[]'
tail -f /usr/local/cpanel/logs/access_log | grep passwd

Confirm the token has the passwd ACL. Slice the account list to those you actually need to rotate — not every account is affected by every breach.

The fix

  1. Generate strong passwords that get stored in your password vault keyed by username, never emailed. A 24-character random string with mixed case, digits, and symbols passes any cPanel complexity check:
while IFS= read -r user; do
  newpw=$(openssl rand -base64 24 | tr -d '=/+' | head -c 24)
  vault kv put "secret/cpanel/$user/2026-05" value="$newpw"
  whmapi1 passwd user="$user" password="$newpw"
  sleep 1
done < /tmp/affected-accounts.txt
  1. Pace the rotation at one per second. whostmgrd handles concurrent password changes but the audit log becomes hard to read at high concurrency.
  2. Notify customers through the channel they expect — a billing-system message, not a raw cPanel notification. Include the password-reset path (the cPanel “I forgot my password” flow) rather than the new password itself. Customers reset to a password they remember; you keep the auditable trail of vault-stored backstops.
  3. Audit the rotation afterwards: grep -c passwd /usr/local/cpanel/logs/access_log against your /tmp/affected-accounts.txt count. Any discrepancy is a rotation that didn’t complete.
  4. Force customers to change again at next login by setting a “must change password” flag if cPanel supports it on your version, or by following up the bulk rotation with a per-customer ticket that asks them to log in and set a password they’ll remember.

Mass credential events are exactly where Stack Harbor’s deployment management practice earns its keep — the rotation, the audit, the customer comms, and the cleanup all run on the same playbook so the customer experience stays consistent across a thousand accounts.