Lost your root password? Well, this is very unfortunate! This tutorial will show you how to reset ESXi root password.
There is no supported method to “reset” the root password, VMware suggest to boot from ESXi installer disk and select “Install ESXi, preserve VMFS datastore” option. This will overwrite the current installation (fresh install, overwriting all configuration) but preserve the VM stored in the datastore. If you don’t want to lose your configuration and having to re-import all the VMs into the host inventory, the following manual procedure will show you how to really just reset the password.
You need a Linux Live or Rescue CD to perform this action. You can use RHEL/CentOS using the rescue mode, SysRescue CD, Knoppix or your favorite portable Linux distro.
1. Boot on your Live CD
2. Create two temp folders under /mnt :
mkdir /mnt/sda5 mkdir /mnt/sda6
3. Mount the dual root ESXi system partitions into the folders you just created :
mount /dev/sda5 /mnt/sda5 mount /dev/sda6 /mnt/sda6
Now, move in the first volume (sda5) :
cd /mnt/sda5
4. Create a safety copy first of the file you are about to edit :
cp -p state.tgz state.tgz.bak
5. Untar state.tgz archive :
tar xzf state.tgz
(This will extract local.tgz)
6. Untar local.tgz archive :
tar xzf local.tgz
(This will extract ‘etc’ folder. You might get some outputs during the extraction about permissions, it’s safe to ignore.)
7. Edit ‘shadow’ file (this is the file where the user passwords are stored, encrypted of course) :
vi etc/shadow
8. At the top line, you should see “root:” followed with alpha numeric characters, which is the encrypted password. Simply erase everything after ” : ” and enter the following :
$1$1wX62qTk$dgXJsh1PRKZnWyx6aDx3..:15831:0:99999:7:::
This line will set the password to “recoverypassword”. You can also create your own by creating a new user on your rescue CD and paste the generated password.
9. Save and exit. Then repack the ‘etc’ folder :
tar czf local.tgz etc
And repack to ‘state.tgz’ :
tar czf state.tgz local.tgz
10. Go back to ‘/mnt’ location and unmount the ‘sda5’ filesystem :
cd ../ umount /mnt/sda5
11. Repeat the exact same steps for ‘sda6’, then reboot.