Shell script to change multiple cPanel account password.

You may need to change the password of all your cPanel account in case of a potential security threat. But doing it manually will take a lot of time especially if you have hundreds of cPanel accounts.You can automate this process by simple shell scripts.

  1. SSH to your VPS with root user.

  2. Create a new file using your favorite editor. In our case, we have created file changecpanelpass.sh and add the below script on it.

    
    #! /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-passwords.txt
    /scripts/realchpass $user $pass
    /scripts/ftpupdate
    done	
  3. Save the file and give it provide executable permission to the script.

    chmod +x changecpanelpass.sh
  4. Execute the script using command sh changecpanelpass.sh

This script will change passwords of all the cPanel account and create a file named new-passwords.txt which contains all the passwords.

  • 0 Users Found This Useful

Was this answer helpful?

Related Articles

How to Restrict Addon Domains Folder Accessing from Main Domain in cPanel?

If you are running your websites under cPanel and have addon domains linked with subdomains and...

How to enable cPhulk in WHM?

cPHulk is a powerful extension that protects your server from the brute force attacks. In this...

What is cPanel?

cPanel is a Web-based control panel provides by Hosting Providers to their clients to manage...

How to install DokuWiki using Softaculous on cPanel?

DokuWiki is a software package that allows you to create an online wiki. It is an open-source...

How to create a catch-all email address in cPanel?

With a catch-all email, you can catch all the emails sent to the users that are not created or...