• If you are still using CentOS 7.9, it's time to convert to Alma 8 with the free centos2alma tool by Plesk or Plesk Migrator. Please let us know your experiences or concerns in this thread:
    CentOS2Alma discussion

Question Password Changing Script

KrazyBob

Regular Pleskian
Years ago I got the attached script from Plesk support but never tried it. I see that it needs to be slightly modified but basically it sets a date on which the passwords will be changed and notifies the clients. I have some Plesk 9-12 servers to upgrade to Onyx but want to change the passwords first. Has anyone tried this script? Modified it?


Plesk - Ensim Encryped Password Email Scripts

# to prepare a list of mail names with new passwords:

mysql -uadmin -p`cat /etc/psa/.psa.shadow` -D psa -e"select concat(m.mail_name, '@', d.name) from domains d, mail m, accounts a where m.dom_id=d.id and m.account_id=a.id and a.type='crypt'" | while read mailname ; do newpass=`tr -dc A-Za-z0-9_%#- < /dev/urandom | head -c 12` ; echo $mailname $newpass ; done > list.txt

# to notify users (please, change the text in quotes):

cat list.txt | while read mailname password ; do echo "Starting 2011-05-10 your mailname account's password will be changed to $password" | mail -s "Password change notification" $mailname ; done

# to change passwords on day X:

cat list.txt | while read mailname password ; do /usr/local/psa/bin/mail -u $mailname -passwd_type plain -passwd "$password" ; done

=====

After further testing on our test environment I have made some corrections to the scripts for web users. Please, use this last version:

# To prepare lists of users with new passwords:

ftpusers: mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` -D psa -e"select s.login, d.name from domains d, hosting h, sys_users s, accounts a where a.type='crypt' and a.id=s.account_id and s.id=h.sys_user_id and h.dom_id=d.id" | while read login; do newpass=`tr -dc A-Za-z0-9_%#- < /dev/urandom | head -c 12` ; echo $login $newpass ; done > ftpusers.txt

ftpsubusers: mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` -D psa -e"select concat(sd.name, '.', d.name), s.login from domains d, subdomains sd, sys_users s, accounts a where a.type='crypt' and sd.dom_id=d.id and sd.sys_user_type='native' and sd.sys_user_id=s.id and s.account_id=a.id;" | while read login; do newpass=`tr -dc A-Za-z0-9_%#- < /dev/urandom | head -c 12` ; echo $login $newpass ; done > subftpusers.txt

webusers: mysql -Ns -uadmin -p`cat /etc/psa/.psa.shadow` -D psa -e"select s.login, d.name from domains d, web_users wu, sys_users s, accounts a where a.type='crypt' and a.id=s.account_id and s.id=wu.sys_user_id and wu.dom_id=d.id" | while read login; do newpass=`tr -dc A-Za-z0-9_%#- < /dev/urandom | head -c 12` ; echo $login $newpass ; done > webusers.txt


# To change passwords:

cat ftpusers.txt | while read login name password; do /usr/local/psa/bin/domain -u $name -login $login -passwd_type plain -passwd "$password" ; done

cat subftpusers.txt | while read login name password ; do /usr/local/psa/bin/subdomain -u $name -login $login -passwd_type plain -passwd "$password" ; done

cat webusers.txt | while read login name password ; do /usr/local/psa/bin/webuser -u $login -passwd_type plain -passwd "$password" -domain $name ; done
 
Back
Top