Skip to content
IT related

Resetting Linux server passwords

Updated 2 min read

Linux Password Recovery Guide (Proxmox/Live ISO)

This document provides a "surgical" method to regain access to a Linux VM by booting from a Live ISO and using a chroot (Change Root) environment to modify the internal user database.

Phase 1: Proxmox Configuration

  1. Attach ISO: In Proxmox, go to Hardware > CD/DVD Drive and select an Ubuntu or NixOS Live ISO.
  2. Set Boot Order: Go to Options > Boot Order and move the CD/DVD drive to the top.
  3. Boot: Start the VM and enter the "Live" environment (e.g., "Try Ubuntu").

Phase 2: Traditional Linux (Ubuntu, Debian, etc.)

Follow these steps for any standard Linux distribution.

1. Identify & Mount the Filesystem

Find your root partition (look for the largest "Linux" partition) and mount it:

sudo fdisk -l
sudo mount /dev/sda2 /mnt

2. Bind Virtual Filesystems

You must bridge the Live ISO's "nervous system" to your hard drive so the system can talk to the hardware.

for i in /dev /dev/pts /proc /sys /run; do sudo mount -B $i /mnt$i; done

Note: If you mounted your disk to a subfolder (e.g., /mnt/oldhdd), ensure the loop reflects that path: ... /mnt/oldhdd$i; done.

3. Enter Chroot and Reset

sudo chroot /mnt
passwd <username>


Phase 3: NixOS (The "Nix Way")

NixOS handles chrooting differently because its binaries are stored in the /nix/store rather than standard locations.

  1. Mount the Disk: sudo mount /dev/sda2 /mnt.
  2. Enter System: Use the specialized tool: sudo nixos-enter.
  3. Reset: Run passwd <username>.
  • Warning: If your configuration.nix has users.mutableUsers = false, this change will be overwritten on the next reboot. In that case, you must edit /mnt/etc/nixos/configuration.nix and set a hashedPassword.

Phase 4: Identifying "Hidden" Users

If the name on the login screen (GDM) doesn't match what you see in /home, follow these steps inside the chroot:

  • Find Real Usernames: GDM shows "Display Names," but passwd requires the "Internal Username."
cut -d: -f1,5 /etc/passwd

  • Column 1: Internal Username (use this with passwd).

  • Column 5: Display Name (what you see on the login screen).

  • Check Human Users: List all users with a UID of 1000 or higher:

awk -F: '$3 >= 1000 && $3 != 65534 {print $1}' /etc/passwd


Phase 5: Cleanup & Exit

To prevent filesystem corruption, unmount everything cleanly before restarting.

  1. Exit: Type exit (to leave chroot/nixos-enter).
  2. Unmount:
for i in /run /sys /proc /dev/pts /dev; do sudo umount /mnt$i; done
sudo umount /mnt

  1. Finalize: In Proxmox, revert the Boot Order so the Hard Disk is first, then reboot the VM.

Troubleshooting

  • "Authentication token manipulation error": The disk is Read-Only. Fix: mount -o remount,rw /.
  • "Mount point does not exist": Your for loop path does not match where you mounted the disk. Double-check your /mnt folder name.
IT related RSS feed Published with Oblish

Keyboard shortcuts

/
Search
[
Previous page
]
Next page
?
Show this list
Esc
Close