richardglover.co.uk

Geek, part-time cyclist, ecoist, bad photographer, vegetarian. I fiddle with WordPress and Edu Tech.

Tag: root

Plesk root password recovery

I was doing a password rotation on a server the other day and for some reason it failed whilst I was updating root. Maybe the password was too long, maybe Virtuozzo doesn’t do proper validity checking but either way I lost access to root.

Luckily if you’ve still got access to a Plesk admin user you can use this to your advantage and get root access back.

First of all you need a user with SSH access, in the Plesk admin panel make sure the account is set up with ‘/bin/bash’ as the root directory and not ‘/bin/bash (chrooted)’.

SSH into the server with that users’ credentials and create two scripts, the first one:

#!/bin/bash
cp /etc/shadow /tmp/shadow.tmp;
chmod 777 /tmp/shadow.tmp;
exit;

The second:

#!/bin/bash
cp /tmp/shadow.tmp /etc/shadow;
chmod 640 /etc/shadow;
exit;

Place them in /tmp or wherever you want to run them from and name them what you like, I’ll refer to them as 1.sh and 2.sh from here on.

Give the scripts execute permissions:

chmod +x /tmp/1.sh /tmp/2.sh

Now go back to your Plesk admin panel and go to Server > Tools & Resources > Scheduled Tasks.

Search for or select the user ‘root’ and add a new task.

Enter */1 in the Minute field and * in the rest of them, in the Command field enter the path to your first script, most probably /tmp/1.sh.

Hit the OK button.

This cron job will run the first script once a minute, on the minute so wait a minute and it will have made a copy of the /etc/shadow file called /tmp/shadow.tmp, check your /tmp folder for this.

Once the file has appeared, remove the task in the Plesk admin panel so it stops copying the file every minute.

In your SSH session open /tmp/shadow.tmp in your favourite editor.

Copy the whole line for a user that you know the password of, you might want to choose the line that matches the SSH user you’re currently using as you definitely know that password.

Replace the line (most probably at the top of the file) for the root user with the one you’ve just copied and then change the username at the beginning of the line from whatever user it is to ‘root’, save your file making sure it’s still called ‘shadow.tmp’.

Now go back to the Plesk admin panel and make a new scheduled task, exactly the same configuration as before but set the command to be ‘/tmp/2.sh’.

Hit the OK button on the task and wait 1 minute for the task to run, after a minute remove the task so it doesn’t carry on running the script. If you’ve done everything right you’ll have replaced the password hash for the root user with a known password and you’ll be able to log in as root using this known password.

Once you’ve logged back in change the root password and clear up the files in your /tmp folder.

Let me know how you get on, I know the scripts could be cleaned up and consolidated but I didn’t want to use a delay so that I wasn’t rushed in making sure I’d edited the files in time, it was easier just to run two cron jobs.

Ice Cream Sandwich on the HTC Desire

I got my HTC Desire back at the beginning of 2010, my second Android phone because I liked the Hero so much. It came with Froyo and HTC made a Gingerbread update available in 2011.

The Desire only has 512MB of flash memory, when HTC made the Gingerbread update they repartitioned the flash to make more space for /system and less for /data, one problem with this is that there’s now only 147MB available for /data.

Because on this I’ve always had to run a tight ship app wise on my Desire, HTC bundled Facebook and Flash with their ROM, these took up a lot of space on /data.

I stumbled across this thread over at xdadevelopers, Sandvold and others have been working on getting ICS working on the Desire and as it turns out they’ve done one hell of a job!

Ice Cream Sandwich

Ice Cream Sandwich

I grabbed the latest ROM from http://www.sandvold.as, rooted my phone with Revolutionary and set to work.

A few minutes later I had ICS on my Desire, it’s still very much in beta but it’s running Android 4.0.3 with pretty much full hardware support and it has more free space in /data, but wait, this is where Apps2SD comes to the rescue!

Apps2SD makes your phone think your SD card is part of the internal storage and essentially extends /data onto it so everything to do with an application and system caches can be stored there! So as long as you have a class 4 or above card in your phone it really does help extend the life of the Desire.

A few issues…

It’s beta and it seems to have a few issues but nothing to stop me using it every day…

  • After A2SD has been installed the ring and notifications tones are fairly quiet.
  • The camera shutter sound is always on, even when the phone is set to silent.
  • Sometimes when you press and hold a key on the keyboard for the pop up shortcuts you have to move your finger well away from the character you want to select to actually select it.
  • No video recording or panorama in the Camera app.
  • No USB mass storage mode support, ICS is supposed to support MTP on Windows but that doesn’t work either. You can however reboot to ClockworkMod recovery and enable USB mass storage mode there.
  • Sometimes the Screen Lock enables itself immediately when you put the phone to sleep even if it is set to lock 2 minutes after sleep.

© 2017 richardglover.co.uk

Theme by Anders NorenUp ↑