Root Password Reset: Difference between revisions

From Proxmox VE
Jump to navigation Jump to search
m (fix typo)
Line 17: Line 17:
** For <code>systemd-boot</code> the kernel commandline is directly editable
** For <code>systemd-boot</code> the kernel commandline is directly editable
* Scroll to the end of that line, optionally remove the <code>quiet</code> in the line and append <code> init=/bin/bash</code>
* Scroll to the end of that line, optionally remove the <code>quiet</code> in the line and append <code> init=/bin/bash</code>
* For <code>grub</code> press <code>Ctrl X</code> to boot, for <code>systemd-boot</code> simply press Enterg
* For <code>grub</code> press <code>Ctrl X</code> to boot, for <code>systemd-boot</code> simply press Enter


In the resulting shell:
In the resulting shell:

Revision as of 15:37, 22 January 2024

Resetting the root account password on the PVE Host

The following follows the general method for resetting a root password on a Linux machine, if you have access to the console see e.g.:

for similar suggestions.

Keep in mind that editing the kernel command-line might need a different key-entry based on your boot-loader (e works for both grub and systemd-boot though). The method works for Proxmox VE until version 8.1 and should work for many other Linux based Operating systems as well:

Method 1

  • Boot into your bootloader (mostly grub or systemd-boot, select your preferred kernel but do not press enter.
  • Press e to go into edit mode.
  • Depending on the boot-loader go to the kernel-commandline entry:
    • For grub: scroll down to the kernel line you will boot from, it starts with linux /vmlinuz-...
    • For systemd-boot the kernel commandline is directly editable
  • Scroll to the end of that line, optionally remove the quiet in the line and append init=/bin/bash
  • For grub press Ctrl X to boot, for systemd-boot simply press Enter

In the resulting shell:

# Remount / as Read/Write 
mount -o remount,rw /
# Change the root account password with
passwd
# Change any other account password with
passwd username
# type new password, confirm and hit enter and then reboot.


Method 2

  • Boot from a Live CD, which supports the / filesystem of your PVE installation (mostly relevant for installs on ZFS) (e.g. a Proxmox install ISO, in debug-mode (second debug-shell))
  • Mount the / filesystem in read-write mode at a free directory (e.g./mnt will be used in this example).
    • you might need to do other steps, based on the filesystem, e.g. zpool import -f -R /mnt rpool for ZFS.
  • Run passwd -R /mnt to set a new password for the root account.
  • Unmount/export the /-filesystem and reboot.

Resetting the root account password in a Container

  • Enter the working container and change the password using:
pct enter <VEID>
passwd <new password>
exit

  • When using OpenVZ containers (up to PVE 3.4) use


vzctl enter <VEID>

to enter the container.

References