Root Password Reset: Difference between revisions

From Proxmox VE
Jump to navigation Jump to search
(Created page with "== Debian Squeeze change root password == === Method 1 === * Boot into '''grub''', select '''''single user''''' but '''do not press enter'''. * Press '''e''' to go into '''edit''…")
 
 
(16 intermediate revisions by 5 users not shown)
Line 1: Line 1:
== Debian Squeeze change root password ==
== 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.:
* [https://www.debian.org/doc/manuals/debian-reference/ch04.en.html#_securing_the_root_password the Debian Handbook]
* [https://wiki.archlinux.org/title/Reset_lost_root_password the Arch Linux Wiki entry]
* [https://en.wikibooks.org/wiki/Linux_Guide/Reset_a_forgotten_root_password the entry in WikiBooks]
for similar suggestions.
 
Keep in mind that editing the kernel command-line might need a different key-entry based on your boot-loader (<code>e</code> works for both <code>grub</code> and <code>systemd-boot</code> 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 ===
=== Method 1 ===
* Boot into '''grub''', select '''''single user''''' but '''do not press enter'''.
* Boot into your bootloader (mostly <code>grub</code> or <code>systemd-boot</code>, select your preferred kernel but '''do not press enter'''.
* Press '''e''' to go into '''edit''' mode.
* Press '''e''' to go into '''edit''' mode.
* Scroll down to the '''kernel''' line, it starts with "<tt>linux /boot/vmlinuz-2.6…….</tt>"
* Depending on the boot-loader go to the kernel-commandline entry:
* Scroll to the end of that line and press '''space key''' once and type <tt>init=/bin/bash </tt>
** For <code>grub</code>: scroll down to the <code>kernel</code> line you will boot from, it starts with <code>linux /vmlinuz-...</code>
* Press '''Ctrl X''' to boot
** 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>
* For <code>grub</code> press <code>Ctrl X</code> to boot, for <code>systemd-boot</code> simply press Enter


<source lang="bash">
In the resulting shell:
# Remount / as Read/Write  
# Remount / as Read/Write  
mount -rw -o remount /
mount -o remount,rw /


# Change password with
# Change the root account password with
passwd
passwd
 
# Change any other account password with
passwd username
 
# type new password, confirm and hit enter and then reboot.


# type new password, confirm and hit enter and then reboot.
</source>


=== Method 2 ===
=== Method 2 ===
* Boot from another installation of Debian. (One can use a LiveCD to get access to the "/" partition.)
* Boot from a Live CD, which supports the <code>/</code> filesystem of your PVE installation (mostly relevant for installs on ZFS) (e.g. a Proxmox install ISO, in debug-mode (second debug-shell))
* Then, mount the partition where you have Squeeze's "/", then changed directory to '''/mnt/etc'''
* Mount the <code>/</code> filesystem in read-write mode at a free directory (e.g.<code>/mnt</code> will be used in this example).
* Used '''vim / nano''' as an editor to edit the file '''shadow'''.
** you might need to do other steps, based on the filesystem, e.g. <code>zpool import -f -R /mnt rpool</code> for ZFS.
* Find the line starting with '''root:'''
* Run <code>passwd -R /mnt</code> to set a new password for the <code>root</code> account.
* Delete everything between the first and second colons (:), and the line will now look like:
* Unmount/export the <code>/</code>-filesystem and reboot.
  root::$6$fsdsdgdsg74.:14862:0:99999:7:::
 
* Reboot as '''root''' without a password.
== Resetting the root account password in a Container ==
* At the end use '''passwd''' to set a new root password.
* Enter the working container and change the password using:
* Reboot and login as '''root''' with the new root password.
   
pct enter <VMID>
passwd
# enter new password in silent prompt
exit
 
* If you're still using OpenVZ containers, which are not supported in Proxmox VE 4 or newer, you can use <code>vzctl enter <VEID></code> to enter the container.


== References ==
== References ==
* [http://derwynd.com/2011/04/14/debian-squeeze-change-root-password/ Debian Squeeze change root password]
* [http://c-nergy.be/blog/?p=1777 Griffon's IT Library] - [[Media:Debian-PVE-root-Password-Reset_pdf.zip|Cache]]
* https://wiki.debian.org/Root


[[Category: HOWTO]]
[[Category: HOWTO]] [[Category:System Administration]]

Latest revision as of 15:49, 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 <VMID>
passwd
# enter new password in silent prompt
exit
  • If you're still using OpenVZ containers, which are not supported in Proxmox VE 4 or newer, you can use vzctl enter <VEID> to enter the container.

References