I managed to somehow lose the root password for the vCenter Server Appliance in my home lab – I had the documentation and I know the password has worked in the past, but it had been a while since I had to log in to the shell. I managed to reset it using the following:
Download openSUSE Rescue CD (I used x64 version 13.1) – Link
Set the VM to boot from the CD and it will load – select openSUSE from the boot menu, then at the login screen change the user to root. The password is blank.
Load X Terminal and type:
mount /dev/sda3 /mnt cd /mnt cp shadow shadow-bak chmod +w shadow vi shadow
Find the line for root and change the encrypted password to:
$6$KZ4N.p6e$bFJsFru19eVPiYvIEsTvVAtdGK/bx/ap5j8yl2e21L2VHyd/KVQf4qRQVKtfVRHyNVkbfgq07KlMkzvOcnO8D1
Note – if copy/pasting to the VM won’t work (common in VMs with no VMware tools loaded), type the following to set the password in the live/rescue CD session:
passwd Password prompt: vmware Re-enter Password: vmware vi /etc/shadow
Copy the password against the root user, quit then edit /mnt/etc/shadow and enter the new encrypted password in there.
The complete line should look like:
root:$6$KZ4N.p6e$bFJsFru19eVPiYvIEsTvVAtdGK/bx/ap5j8yl2e21L2VHyd/KVQf4qRQVKtfVRHyNVkbfgq07KlMkzvOcnO8D1:15976:0:90:7:::
Reboot the VM (don’t forget to eject the CD), then login with username of root and password vmware 🙂
Account Past Expiry Date
There is also a chance the password has expired and needs changing – only you can’t log in to change it. Boot to the rescue live CD as above and mount /dev/sda3 into /mnt, and edit the /mnt/etc/shadow file – find the same line for root and if the encrypted password has an ‘x’ as the first character then the password has expired. Simply remove the ‘x’ and change the ’90’ which appears later in the line signifying 90 days since the password was last changed to ‘9999’, save and reboot. See the screenshot below: