Tech Tip: Linux password recovery

How many cloud VM you have? Where do you store root credentials? How many time you forgot it? If you run amazon EC2 machine is simple handling password recovery, because it uses key-pair system to handle system authentication; but in traditional Infrastructure as a service, where you simply rule virtual machines from their console, there are two procedure that could aid you to restore user credentials.

Note: all of these methods must be executed during service downtime, because require VM to be run I single out of its normal execution.

External system with clonezilla

  • Download cloneezilla live iso here:
  • Upload and/or attach iso file to VM
  • Reboot VM starting this iso as boot image.
  • After clonezilla system is ready, enter in shell mode
  • mount local root filesystem

  • chroot into /mnt/

  • execute passwd to wanted user


Run in usermod (not for all Distro!)

  • Before grub load kernel image, press e
  • Edit the kernel line adding “single” after “ro” (before “quiet”)
  • Add the following line at the end

  • Press F10 key to continue the execution with these parameters
  • After boot is complete you should see the root prompt.
  • Mount the root partition with this command

  • execute passwd to wanted user

On RHEL/CentOS 7

Thanks to my friend Giuseppe Merigo (@gmerigo) and CertDepot, this procedure well explain how to do in RHEL7:

In brief: editing grub and simply add the following at the the end of kernel line:

then mount /sysroot and chroot it.

   Send article as PDF