Plesk useful password related tips

Useful things to add to your aliases file to retrieve plesk passwords:

mailpwd()
{
if [ $# -eq 1 ]; then
MYSQLPWD=`cat /etc/psa/.psa.shadow`
DOMAIN=$1;
#query mysql db for domain name
QUERY="SELECT CONCAT_WS('@',mail.mail_name,domains.name),accounts.password FROM domains,mail,accounts WHERE domains.id=mail.dom_id AND accounts.id=mail.account_id AND domains.name = '$DOMAIN';";
mysql -B -uadmin -p`echo $MYSQLPWD` -D psa -e"$QUERY";
else
echo "Function mailpwd requires 1 argument - a domain name"
fi
return;
}

ftppwd()
{
if [ $# -eq 1 ]; then
MYSQLPWD=`cat /etc/psa/.psa.shadow`
DOMAIN="/var/www/vhosts/"$1;
#query mysql db for domain name
QUERY="SELECT REPLACE(sys_users.home,'/home/httpd/vhosts/','') AS domain, sys_users.login,accounts.password FROM sys_users LEFT JOIN accounts on sys_users.account_id=accounts.id WHERE sys_users.home = '$DOMAIN';";
mysql -B -uadmin -p`echo $MYSQLPWD` -D psa -e"$QUERY";
else
echo "Function ftppwd requires 1 argument - a domain name"
fi
return;
}

dbpwd()
{
if [ $# -eq 1 ]; then
MYSQLPWD=`cat /etc/psa/.psa.shadow`
DOMAIN=$1;
#query mysql db for domain name
QUERY="SELECT domains.name AS domain_name,data_bases.name AS database_name, db_users.login, accounts.password FROM data_bases, db_users, domains, accounts WHERE data_bases.dom_id = domains.id AND db_users.db_id = data_bases.id AND db_users.account_id = accounts.id AND domains.name = '$DOMAIN';";
mysql -B -uadmin -p`echo $MYSQLPWD` -D psa -e"$QUERY";
else
echo "Function dbpwd requires 1 argument - a domain name"
fi
return;
}

alias qstat='/var/qmail/bin/qmail-qstat'
alias qread='/var/qmail/bin/qmail-qread | less'

From a shell script usage is as follows:

mailpwd domainname.com – This will get you all the usernames & passwords for all the mail accounts under a domain.

ftppwd domainname.com – This will get you all the ftp usernames & passwords for all the ftp accounts under a domain.

dbpwd domainname.com – This will get you all the database usernames & passwords for all the db accounts under a domain.

Hope its useful.

Leave a Reply

Your email address will not be published. Required fields are marked *