Saturday, January 19, 2019

CentOS7 Root Password Recovery

Highly condensed set of steps to recover root password. Tested in RHEL7, CentOS7 and Fedora29.

  1. At grub boot menu, press 'e' key on desired menu item.
  2. Scroll down to line with linux[16] vmlinuz
  3. Append the following options to the end of this line.
    rd.break enforcing=0 systemd.unit=emergency.target
  4. Ctrl-x
  5. mount -o remount,rw /sysroot
  6. chroot /sysroot
  7. passwd #enter new root password as prompted
  8. exit  #chroot
  9. exit  #continue original boot
    Allow system to boot emergency target. Do not issue a reboot here.
  10. Login with new root password
  11. ls -lZ /etc|grep unlabeled
    Likely the following two files will be unlabeled:
    - /etc/shadow
    - /etc/fstab
  12. restorecon /etc/shadow
  13. restorecon /etc/fstab
  14. reboot  #allow normal boot

No comments:

Post a Comment

KVM VM install failure with virt-install

I've been working quite a bit lately with CentOS and KVM. This includes Fedora and RedHat releases. Most of my VM creation has been done...