change all user cpanel password

mojamoi

Well-Known Member
Jul 23, 2007
187
0
66
how to change all user cpanel password for 300 users in one time using SSH or WHM ?

any simple script
 

MattLee

BANNED
Aug 26, 2009
83
0
56
Hello,

There is not a method within cPanel or WHM to mass change account passwords. This would more than likely need to be done manually by you on an account by account basis unless you feel comfortable enough writing a script that utilizes the 'passwd' command in a loop for every user on the server.
 

cPanelTristan

Quality Assurance Analyst
Staff member
Oct 2, 2010
7,607
40
248
somewhere over the rainbow
cPanel Access Level
Root Administrator
Hello,

I wanted to further mention that if you use passwd, it doesn't sync up the FTP passwords for the users either, so you should instead be calling the following to change the passwords:

Code:
/scripts/realchpass username password
Additionally, this script does not handle the MySQL password any longer and you then need to call this script to change the MySQL password for the user:

Code:
/scripts/mysqlpasswd username password
For both of the above examples, username is the cPanel username and password is the MySQL password.

Again, to re-iterate, please do not use passwd for changing passwords, the cPanel and FTP passwords are handled by /scripts/realchpass and the MySQL passwords are handled by /scripts/mysqlpasswd scripts. If you use passwd, then only the cPanel password will change and not be synced with the FTP or MySQL passwords. If you use only /scripts/realchpass, then the MySQL password won't be changed. You must use both scripts to get the password changed for all 3 services.

Thanks.
 

gkgcpanel

Well-Known Member
Jun 6, 2007
214
1
166
cPanel Access Level
DataCenter Provider
FYI: This alone will not work. I ran /scripts/realcphass username password for a bunch of accounts that were compromised via FTP. But afterwards was still able to log in with the old password. Not until I went into WHM and ran "Synchronize FTP Passwords" did it work. After that the old password no longer worked, and the new one did.

Posting this in case anyone else runs into this problem.
 

JaredR.

Well-Known Member
Feb 25, 2010
1,834
23
143
Houston, TX
cPanel Access Level
Root Administrator
In addition, you can force cPanel users to change their own passwords by clicking, in the WebHost Manager, Main >> Account Functions >> Force Password Change. You can use this to force some or all cPanel users to change their passwords the next time they log in.
 

vmicovic

Well-Known Member
Sep 4, 2007
95
0
56
Hello,

i have same question and found script "/usr/local/cpanel/scripts/realchpass"
Can this help for changing all passwords for user?

and script for changing will be something like:

1. take all usernames in one file
ls -la /home | awk '{print $3}' | grep -v root | grep -v wheel | grep -v cpanel | grep -v apache >> list.txt
2. change passwords:
Code:
#!/bin/sh
for i in `more list.txt `
do
echo $i
/scripts/chpass $i NEWPASSWORD
done
only, i want random passwords, so for now this script is not finish, i will add variable for newpassword to "take" passwords from file.


So, question, can i use "/usr/local/cpanel/scripts/realchpass" to change users passwords?




thank you.
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,225
463
i have same question and found script "/usr/local/cpanel/scripts/realchpass"
Can this help for changing all passwords for user?
Yes, this script is the same one that Tristan mentioned above. The only difference is the path to the script.

Thank you.
 

vmicovic

Well-Known Member
Sep 4, 2007
95
0
56
thank you for answer.
Last question, did i must after realchpass to use /scripts/mysqlpasswd ?
and after changing must do ftp sync with script "/scripts/ftpupdate"
 
Last edited:

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,225
463
Last question, did i must after realchpass to use /scripts/mysqlpasswd ?and after changing must do ftp sync with script "/scripts/ftpupdate"
Yes, you must use "/scripts/mysqlpasswd" to ensure the MySQL password is changed. The FTP password is updated when you use "/scripts/realchpass".

Thank you.
 

vmicovic

Well-Known Member
Sep 4, 2007
95
0
56
Yes, you must use "/scripts/mysqlpasswd" to ensure the MySQL password is changed. The FTP password is updated when you use "/scripts/realchpass".

Thank you.
hmm, i don`t understand which sql password he change with that script?
and when i change with realchpass he only change for cpanel, not for ftp, so then i do "/scripts/ftpupdate" and all pass ok.

tomorrow i will put script, if someone need it.
 

vmicovic

Well-Known Member
Sep 4, 2007
95
0
56
Hi,

here is new script:
#!/bin/bash
str0="$$"
for i in `more users.txt `
do
POS=2
LEN=8 # Make password 8 characters.
str1=$( echo "$str0" | md5sum | md5sum )
randstring="${str1:$POS:$LEN}"
let str0=str0+5
echo "$i $randstring" >> newpass.txt
/usr/local/cpanel/scripts/realchpass $i $randstring
/scripts/ftpupdate
done
Only left Michael to tell us, is recommend to use mysqlpasswd at the end.
 

cPanelMichael

Administrator
Staff member
Apr 11, 2011
47,909
2,225
463
Only left Michael to tell us, is recommend to use mysqlpasswd at the end.
Yes, you should use "/scripts/mysqlpasswd" because it ensures the MySQL password for the account username is updated. Otherwise, the user will encounter authentication errors when attempting to access PHPMyAdmin from within their cPanel.

Thank you.