• Please be aware: Kaspersky Anti-Virus has been deprecated
    With the upgrade to Plesk Obsidian 18.0.64, "Kaspersky Anti-Virus for Servers" will be automatically removed from the servers it is installed on. We recommend that you migrate to Sophos Anti-Virus for Servers.
  • The Horde webmail has been deprecated. Its complete removal is scheduled for April 2025. For details and recommended actions, see the Feature and Deprecation Plan.
  • We’re working on enhancing the Monitoring feature in Plesk, and we could really use your expertise! If you’re open to sharing your experiences with server and website monitoring or providing feedback, we’d love to have a one-hour online meeting with you.

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