Cpanel force password change

For changing all users cpanel logins the next time they login go to
Main >> Account Functions >> Force Password Change in WHM and then Select All,
then Submit

From techtrunch.com

There is a cPanel script [chpass] to reset each user’s password. Its syntax is as follows


/scripts/chpass username password

After running the script always run the following script


/scripts/ftpupdate

Using the above cPanel script I have created my own script to change all users password in one shot.


#/bin/bash

cat /etc/trueuserdomains | sort -t" " -k2 > LIST.txt
exec 7<> LIST.txt
for i in `cat /etc/trueuserdomains | awk '{ print $2 }' | sort`; do
read < &7 DAT=$(date +%S%H%M%S) NAM=`echo $i | awk '{ print substr($1,3) }'` /scripts/chpass $i "#"$NAM$DAT echo $REPLY "#"$NAM$DAT >> pass
sleep 1
done
/scripts/ftpupdate

What actually this script is doing?

01. Makes a sorted list of ‘/etc/trueuserdomains’ [sort with usernames] in a file ‘LIST.txt’
02. A File Descriptor opened for ‘LIST.txt’
03. Opened a for loop to itarate each users in ‘/etc/trueuserdomains’
04. Read the first line in the FD and remove the same on each iterartion
05. Store a date format in a variable for generating password
06. Store a part of user name, say from third character of the name to last character, in varaible for complicating the generated password
07. Executing the cPanel password changing script with appropriate parameters
08. Outing the information [Domain Name, User Name and New Password] to a file named “pass” on each iteration
09. Making a delay of 1 second on each iteration
10. Ending the for loop
11. Running cPanel password synchronization script.

===============================

More information regarding changing passwords in bulk:

http://bash.cyberciti.biz/security/linux-batch-mode-password-update/

===============================

http://bash.cyberciti.biz/security/change-password-shell-script/

===============================

another method:


#! /bin/bash
for i in `awk -F: '{print $2}' /etc/trueuserdomains`
do
tmp=`mkpasswd -l 10`
/scripts/chpass $i $tmp
echo "$i $tmp" >> newpasswds
done

Save this in a .sh or some file and give exec perm chmod +x filename and then run it. You will get all new users and passwords from newpasswds file in running location.

g33kadmin

I am a g33k, Linux blogger, developer, student and Tech Writer for Liquidweb.com/kb. My passion for all things tech drives my hunt for all the coolz. I often need a vacation after I get back from vacation....