So the server admin forgets the root password (*cough* me *cough*) but you still have the plesk ‘admin’ login, here’s how to reset the root password on the plesk box:
(it’s a bit technical, I might dumb it down a bit one day and/or make a copy/paste solution)
First, you need a normal ssh user account. If you don’t have SSH access yet, you can enable SSH access on one of your hosting accounts (in the area you set the FTP password). Choose the /bin/bash option (not the chrooted one).
Second, login to that SSH account using putty or your favorite SSH client. Create a bash script called “/tmp/getpassword.sh” with this content in it (ps: /tmp/ is just a generic path for this demo, use the cwd if you want):
cp /etc/shadow /tmp/foo.temp;
chmod 777 /tmp/foo.temp;
cp /tmp/foo.temp /etc/shadow;
chmod 640 /etc/shadow;
Third, save and give script execute permissions:
$ chmod +x getpassword.sh
Fourth step: go back to Plesk, click Server > Cron. Then select “root” in the user drop down list. Create a new cron tasks with */1 in the mins box. * in all the other boxes, and /tmp/getpassword.sh in the command box (use whatever path to your shell script above).
Fifth step, wait a bit.
Sixth step, go back to SSH there should be a /tmp/foo.temp file (or wherever you choose to copy the shadow file to). Open this up in vim or whatever, delete the old ‘root’ entry at the top of the file. Copy the encrypted password for the account that you know, paste it at the top of the file, rename the username to root. Save the file. Wait a few mins.
The cron job will copy your modified shadow file back over the original, and you can now su to root with the password you know.
Disable the cron job.
clean up after yourself, dont leave the temp shadow file around, and best not to use /tmp/ put it all in a less obvious folder (ie: your home folder).