Lost ESXi root password? Here is a way to restore it…

I lost my root password for a LAB ESXi 5.5 & ESXi 6.0 host. VMware KB said we have to reinstall the ESXi as there is no standard way to recover it.

Below is tutorial to show you how to reset lost ESXi root password.

You need a Linux Live CD to perform this action. You can use RHEL/CentOS/Ubuntu live cd’s.

1. Boot on your Live CD (I used Ubuntu here)

1

2. Create two folders under /mnt

mkdir /mnt/sda5
mkdir /mnt/sda6

b

3. Mount the ESXi system partitions(dual) into the folders you created. (If the partition is single partition then use sda5 only)

mount /dev/sda5 /mnt/sda5
mount /dev/sda6 /mnt/sda6

zz

4. Move in the first volume (sda5) :

cd /mnt/sda5

4. Create a copy of the file(state.tgz) for Safety purpose

cp -p state.tgz state.tgz.bak

5. Copy of the file(state.tgz) to /tmp and move to /tmp

cp state.tgz /tmp

cd /tmp

6. Untar state.tgz with the following command

tar xzf state.tgz

This will extract local.tgz

7. Untar local.tgz

tar xzf local.tgz

This will extract ‘etc’ folder.

c

8. Run the vi shadow command to open the shadow file in the vi editor.  (this is the file where the user passwords are stored, encrypted of course)

vi shadow

10

To remove the existing root password, you need to delete the password hash.

g

9. Save and exit. Then repack the ‘etc’ folder :

tar czf local.tgz etc

Then repack to ‘state.tgz’ :

tar czf state.tgz local.tgz

11

Copy the State.tgz to /mnt/sda5 location

cp state.tgz to /mnt/sda5

10. Go back to ‘/mnt’ location and unmount the ‘sda5’ filesystem :

umount /mnt/sda5

11. If its a dual boot  repeat the exact same steps for ‘sda6’, then reboot. if not reboot directly

12. Keep the password field blank and you can log into the root account.

xx

Now you’ve successfully reset lost root password on VMware ESXi host.

Note : This is not a official version and not recommended by VMware. Make sure you take all precautions before trying in a Production Environment.

Leave a comment