Forgot your VMware ESXi Server root password? Try to log on to your ESXi server but for some reason your root password isn’t working anymore? Here we’ll show you a way to reset forgotten root password on VMware ESXi 5 and ESXi 4. But this trick is not officially supported by VMware, so do it on your own risk.
How to Reset Forgotten Root Password on VMware ESXi 5 and ESXi 4?
VMware vSphere Host Profiles – The organization uses vSphere Enterprise Plus licensing. The is a VMware KB which mentions root password recovery is this one and it clearly states that it’s not supported to reset passwords on ESXi 6.x and ESXi in general as there is no longer the Linux console where you would use the single-user mode for the.
- First of all, you need to boot your ESXi server with a Linux live CD. I prefer GRML, but any live CD will do. Of course, you can also boot from a USB stick.
- Find the partition containing a file named “state.tgz”. For my installation, it was on a VFAT filesystem labelled “Hypervisor3”, which is accessible in GRML at “/mnt/Hypervisor3”. You might need to mount it manually with the command
mount /mnt/Hypervisor3
- Unpack the “state.tgz” file somewhere. It contains exactly one file, which is another archive named “local.tgz”.
cd /tmp
tar xzf /mnt/Hypervisor3/state.tgz - Unpack the “local.tgz”, and find an “etc” directory containing several configuration files.
tar xzf local.tgz
- Edit the file etc/shadow to change the password.
vi etc/shadow
Probably the easiest way is to replace the line starting with “root” with the line of another user account of which you know the password. You only need to change the name at the beginning of the line (before the first colon) to “root”. You’ve then set the root password to a password you know.Alternatively, you can just remove the hash altogether (everything between the first and the second colon) and login to the service console as root with no password at all. - Re-pack the files and move the modified state.tgz back to the VFAT partition. Probably it is a good idea to make a backup copy of the original state.tgz in case something goes wrong:
mv /mnt/Hypervisor3/state.tgz /mnt/Hypervisor3/state.tgz.bak
rm local.tgz
tar czf local.tgz etc
tar czf state.tgz local.tgz
mv state.tgz /mnt/Hypervisor3/ - Reboot back into ESXi and you’re done.
Related posts:
Lost or forgot the root password of VMware ESXi host? Is there any way to recover or reset it? Just like many Linux distributions, VMware ESXi also stores user account information, including one-way encrypted passwords, in a file called /etc/shadow. Just boot your server with a Linux Live CD and you can remove the root password easily.
This tutorial explains how to use Ubuntu Live CD to reset forgotten root password on VMware ESXi 5.5, so you can log back into your ESXi server without reinstalling.
![5.5 5.5](/uploads/1/2/5/8/125805072/114615891.jpg)
How to Reset VMware ESXi Root Password with Ubuntu Live CD?
- Boot your ESXi server from Ubuntu Live CD. After a while, the system installer will appear with the option to 'Try Ubuntu' or 'Install Ubuntu'. Click on 'Try Ubuntu' to load Ubuntu directly into RAM, without installing it on your hard drive.
- After getting to the Ubuntu desktop, click on the Ubuntu icon in the upper left corner and search for GParted in the Dash. Double-click on GParted Partition Editor to launch it.
- Now that we know that the partition which we need to mount is /dev/sda5, close GParted and open the Terminal.
- In terminal, type 'sudo -s' to gain root access and then mount the ESXi system partition with the following commands. After mounting, you'll see the state.tgz file that we need to unpack now.
- Copy state.tgz to the /tmp folder, and then unpack the state.tgz file which contains another compressed archive named local.tgz.
- Unpack the local.tgz file which has the /etc directory compressed in it.
- Go to the /etc directory and you can gain access to the shadow file which contains the password hash of ESXi root account.
- Run the vi shadow command to open the shadow file in the vi editor. You'll find out that the password hash of the root account is surrounded by the first two colons. To remove the existing root password, you need to delete the password hash.
- Once you have removed the password hash, press ESC to return to the command mode. Type in :wq and press Enter. This will save your changes and exit the vi editor.
- Re-pack the files and copy the modified state.tgz file back to the ESXi system partition with the following commands:
- We’re almost done! Just type reboot then remove the live CD and wait for ESXi server to restart. After a while, you'll get the following screen where you can configure the system by pressing F2.
- Just keep the password field blank and you can log into the root account.
- Please make sure that you set a new root password and store it confidentially. Do not lose it again.
Look at the partition layout of ESXi 5. The actual hypervisor/system image is located on the first 250 MB partition (/dev/sda5) which contains the state.tgz file.
Now you've successfully reset lost root password on VMware ESXi host. The procedure is a bit complicated so carefully follow the instructions above. Enjoy it!