Reset the VM password
Set a new password on the system disk from rescue mode.
Set a new password on the system disk of a Linux VM. The VM must already be in rescue mode.
The password from the rescue enable form, and any passwd you run in the rescue shell, apply only to the temporary system. That disk is removed when you disable rescue mode, so those passwords do not come back with the VM. The password you set below is written on the system disk and is the one the VM uses after it boots normally.
Before you begin
- Rescue mode is on and you are signed in with an SSH key or through
VM → Console. - The user is the one shown on
VM → Rescue.
Steps
-
List the disks:
lsblk -o NAME,SIZE,SERIAL,FSTYPE,MOUNTPOINTThe disk whose
SERIALisrescueis the temporary system, mounted at/. The other disk is the system disk. On hostd images the root filesystem is the first partition of the system disk, usuallyvda1. -
Mount that partition and change the password. Replace
vda1with the partition from yourlsblk, anddebianwith the VM user.sudo mkdir -p /mnt/system sudo mount /dev/vda1 /mnt/system sudo mount --bind /dev /mnt/system/dev sudo mount --bind /proc /mnt/system/proc sudo mount --bind /sys /mnt/system/sys sudo chroot /mnt/system passwd debian sudo umount -R /mnt/systempasswdasks for the new password twice. The command has to run throughchroot.passwdwithout it changes only the temporary system, and that password is gone when you leave rescue mode. -
Power off the VM:
sudo poweroff. -
Open
VM → Rescueand disable rescue mode. The VM boots from the system disk with the new password.
Watch out
SSH password login is off on hostd images. The new password works on the console. To allow it over SSH as well, turn that on separately: Enable SSH password login.