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.

WHMCS and opensrs API

We use WHMCS at work, its a fantastic piece of software and comes with lots of built in modules for integrating with various registrars, normally you only need your reseller username and password to enable integration with a registrar from WHMCS but in the case of opensrs things are a little different, every domain name has its own username and password rendering the opensrs module in whmcs useless for entering in legacy domains – its great for new domains but for entering old ones no integration is possible with the whmcs opensrs module.

If you are an opensrs reseller you can request from them the ability to view each domains username and password in the opensrs admin control panel (you have to sign an additional agreement).

I have written a module which integrates with opensrs for existing domains – you have to put the domain username and password in the subscription field in whmcs (I do not use this field).

The following actions are supported:

  • Get / save Nameservers
  • Get / save Registrar lock
  • Get / save Contact details
  • Get EPP Code
  • Renew

Features not supported:

  • Register – you should use the normal opensrs module for new domains
  • All the DNS / Email Forwarding functionality
  • Transfer

Download the existing opensrs module

I accept no responsibility for any damanage caused by this module, as with everything – BACKUP FIRST!