Reset VMware vCenter root password

Problem:

The vCenter appliance requires a complex password for the root user, which of course you'll forget after 5 minutes if you're just spinning something up for test purposes.

Naturally what then happens is that vCenter server is used for a whole bunch of stuff until the end of time. Then you hit a problem and need to access the thing to give it more disk space or whatever and you can't get into a shell. Where's that root password when you want it!?

Important: This was performed using vCenter 5.5

Solution:

First, we need to break the GRUB password:
1) Download a bootable linux distro of your choice (I had an ubuntu desktop ISO kicking around), attach it to the vCenter VM
and boot into it. You should then be able to see the disks inside vCenter using fdisk -l:

fdisk -l  

We'll want the first 25GB disk with the /dev/sda1 partition.

2) Create a new directory and mount the volume into it:

Required commands:

cd /mnt  
mkdir vcenter  
mount /dev/sda1 /mnt/vcenter  

Verification Commands:

df -h  
ls /mnt/vcenter  

3) Navigate to the /mnt/vcenter/boot/grub directory and open the menu.lst file. Then delete the password line (or comment it out):

Required commands:

cd /mnt/vcenter/boot/grub  
vi menu.lst  

Verification Commands:

cat menu.lst | grep password  

Now we're finished with the bootable OS. Reboot the machine and remove the CD / ISO file. However be ready to press spacebar when it's rebooting!

Now we edit the grub boot entry:

1) When the machine has rebooted, press space when the grub menu appears:

2) Press e to edit the first entry.

Highlight the middle entry and press e again to edit it

3) Then append init=/bin/bash to the line:

Press enter then then b to save and boot the changes.

The system should boot and come to a shell prompt:

Final piece - resetting the password:

1) Reset the root password using passwd root. You will need a complex password (which includes a special character).

passwd root  

2) Reboot the machine - you won't need to re-edit the grub entry.

The machine should come back up and you can ssh to it with the root user and new password! (This also does the VAMI password).

Command Summary:

# Boot into bootable OS:

# Mount the disk
cd /mnt  
mkdir vcenter  
mount /dev/sda1 /mnt/vcenter  
# Edit / remove the password line:
cd /mnt/vcenter/boot/grub  
vi menu.lst  

Modify GRUB entry file to contain init=/bin/bash

# When booted into the vCenter:

# Reset root password
passwd root