Linux 4 All

Best Linux tricks source

Posts in the plesk category

If you need to get all databases and login credentials from Plesk, the following MySQL query would do the trick:

mysql -uadmin -p`cat /etc/psa/.psa.shadow` -D psa
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
ORDER BY domain_name;

From Plesk 11.5 passwords are encrypted in the database, so this query will no longer return the password, but the hashed version.

Getting Plesk email accounts and passwords is quite easy. Here are few ways of doing that:

mysql -u admin -p$(cat /etc/psa/.psa.shadow) -D psa
SELECT accounts.id, mail.mail_name, accounts.password, domains.name FROM domains LEFT JOIN mail ON domains.id = mail.dom_id LEFT JOIN accounts ON mail.account_id
= accounts.id;

or

mysql -uadmin -p$(cat /etc/psa/.psa.shadow) -D psa 
SELECT mail_name,name,password FROM mail 
LEFT JOIN domains on mail.dom_id = domains.id 
INNER JOIN accounts where mail.account_id = accounts.id;"

or

/usr/local/psa/admin/bin/mail_auth_view

or

mysql -u admin -p$(cat /etc/psa/.psa.shadow) -D psa
SELECT CONCAT(mail_name,"@",name) as email_address,accounts.password FROM mail
LEFT JOIN domains on domains.id=mail.dom_id
LEFT JOIN accounts on accounts.id=mail.account_id;

Some queries might not work on all Plesk versions. From 11.5 upwards the passwords are encrypted, thus only /usr/local/psa/admin/bin/mail_auth_view will work.