This guide explains how to reset the password for every WordPress administrator account across all your WordPress installations, using the Terminal feature built into your DirectAdmin control panel. This is useful if you manage multiple WordPress sites under one hosting account and need to quickly and securely update administrator credentials — for example, after a suspected security incident, or as routine password hygiene.

Note: This guide uses a placeholder username (exampleuser) and placeholder domains throughout. Replace these with your actual DirectAdmin username and domain names where indicated.


Before You Start

  • This method uses WP-CLI, the official WordPress command-line tool, which is pre-installed on our servers. It correctly encrypts (hashes) the new password, unlike editing the database directly.
  • This will reset the password for every user with the Administrator role on each WordPress site found under your account. If a site has more than one administrator account, all of them will receive the same new password.
  • You will need access to Terminal in DirectAdmin. If you don't see this option, please contact support and we can enable it for your account.
  • Choose a strong new password before you begin. In this guide we use YourNewStr0ngP@ssw0rd! as a placeholder — replace it with your own.

Step 1: Log in to DirectAdmin and Open Terminal

  1. Log in to your DirectAdmin control panel.
  2. In the left-hand menu, look under Advanced Features (or use the search bar) and click Terminal.
  3. This opens a command-line session as your own account — in our example, exampleuser. You'll see a prompt similar to:
 
   [exampleuser@server ~]$

If you don't see a Terminal option in your panel, this feature may not be enabled on your account — reach out to support and we'll turn it on for you.


Step 2: Create the Reset Script

Once in the Terminal, create a new file for the script:

 
bash
nano reset-admins.sh

This opens a simple text editor. Paste in the following script, replacing the placeholder password with your own:

 
bash
#!/bin/bash
# Resets the password for every WordPress administrator account
# across all domains under this hosting account.

NEWPASS='YourNewStr0ngP@ssw0rd!'

for dir in /home/exampleuser/domains/*/public_html; do
  [ -d "$dir" ] || continue

  if wp core is-installed --path="$dir" --quiet 2>/dev/null; then
    domain=$(basename "$(dirname "$dir")")
    echo "=== $domain ==="

    wp user list --role=administrator --field=user_login --path="$dir" 2>/dev/null | while read -r admin; do
      wp user update "$admin" --user_pass="$NEWPASS" --path="$dir"
      echo "  -> password reset for admin user: $admin"
    done
  else
    echo "=== $(basename "$(dirname "$dir")") — not a WordPress install, skipped ==="
  fi
done

Important: Replace exampleuser in the path (/home/exampleuser/domains/*/public_html) with your actual DirectAdmin username. You can confirm your username from the DirectAdmin prompt itself, or from the top-right corner of your control panel.

To save and exit in nano:

  • Press Ctrl + O, then Enter (to save)
  • Press Ctrl + X (to exit)

Step 3: Make the Script Executable and Run It

 
bash
chmod +x reset-admins.sh
./reset-admins.sh

The script will loop through every domain folder under your account, check whether it's a WordPress site, and reset the password for each administrator account it finds. You'll see output like:

 
=== example.com ===
  -> password reset for admin user: admin
=== shop.example-store.com ===
  -> password reset for admin user: siteowner
=== oldsite.example.net — not a WordPress install, skipped ===

Optional: Save the output to a log file

If you'd like a record of exactly which accounts were changed and when:

 
bash
./reset-admins.sh | tee ~/admin-reset-$(date +%F).log

This saves a timestamped log file in your home directory that you can review later.


Step 4: Confirm WP-CLI Is Available (If the Script Doesn't Run)

On rare occasions, wp may not be recognized in your shell session. You can check with:

 
bash
which wp

If this returns nothing, try running the script using the full path instead:

 
bash
/usr/local/bin/wp --info

If wp still can't be found, please contact support — WP-CLI may need to be enabled or linked for your account.


Frequently Asked Questions

Will this affect my WordPress content, plugins, or settings? No. This script only updates the password field for administrator accounts. It does not touch posts, pages, themes, plugins, or settings.

Will this log me out of the WordPress dashboard? Yes — any active login sessions for the affected administrator accounts will be invalidated, and you'll need to log back in using the new password.

What if I only want to reset one specific site, not all of them? You can run the wp user update command manually for just that site instead of the full script:

 
bash
wp user update your-admin-username --user_pass='YourNewStr0ngP@ssw0rd!' --path=/home/exampleuser/domains/example.com/public_html

What if I don't recognize one of the administrator usernames listed? Stop and contact support immediately rather than resetting its password. An unfamiliar administrator account can indicate unauthorized access, and simply resetting its password does not remove the account. We can help investigate and remove it safely.

Can I use special characters in my new password? Yes, but if your password contains characters like !, $, &, or *, wrap it in single quotes exactly as shown in the examples above to prevent your shell from misinterpreting them.


Need Help?

If you're not comfortable running terminal commands, or if the script reports errors you're unsure about, contact our support team with the output you're seeing and we'll be happy to assist or run this for you directly.

Помог ли вам данный ответ? 0 Пользователи нашли это полезным (0 голосов)