Home MiscellaneousHow to Change All cPanel Account Passwords Using a Script

How to Change All cPanel Account Passwords Using a Script

by SupportPRO Admin

In certain situations such as security incidents, compromised accounts, or routine security maintenance, administrators may need to reset passwords for all cPanel accounts on a server.

The following script helps automate the process by generating strong passwords and updating them for every cPanel and FTP account.

Step 1: Create the Password Change Script

Create a script file named changepass.sh using your preferred editor:

vi changepass.sh

Add the following content:

#! /bin/bash
ls -1 /var/cpanel/users | while read user; do
pass=`</dev/urandom tr -dc "A-Za-z0-9*-/+.*=_\|\\#" | head -c16`
echo "$user $pass" >> new-pass.txt
/scripts/realchpass $user $pass
/scripts/ftpupdate
done

This script:

  • Generates secure random passwords
  • Updates passwords for all cPanel users
  • Syncs FTP account passwords
  • Saves new credentials in a text file

Step 2: Set Execute Permission

Make the script executable:

chmod +x changepass.sh

Step 3: Run the Script

Execute the script using:

sh changepass.sh

Output

After execution:

  • All cPanel and FTP passwords will be updated.
  • A file named new-pass.txt will be created containing usernames and newly generated passwords.

Important:
Store the new-pass.txt file securely and delete it after distributing credentials to users.

If you require help, contact SupportPRO Server Admin

Facing issues?

Our technical support
engineers can solve it.

Contact Us today!
guy server checkup

You may also like

Leave a Comment