Virtual machines

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

  1. List the disks:

    lsblk -o NAME,SIZE,SERIAL,FSTYPE,MOUNTPOINT

    The disk whose SERIAL is rescue is 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, usually vda1.

  2. Mount that partition and change the password. Replace vda1 with the partition from your lsblk, and debian with 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/system

    passwd asks for the new password twice. The command has to run through chroot. passwd without it changes only the temporary system, and that password is gone when you leave rescue mode.

  3. Power off the VM: sudo poweroff.

  4. Open VM → Rescue and 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.

On this page