In this lab, you will recover a lost root password.
| Resources: | |
|---|---|
| Machines: |
serverX
|
Outcomes:
A recovered root password.
Reset your serverX system.
Log in and set up your serverX system:
[student@serverX ~]$lab rootpw setup
The lab rootpw setup script has just reset your root
password to a random string and rebooted your system. Without using
sudo, break into your own system and reset the
root password back to redhat.
Reboot your system, and interrupt the countdown in the boot loader menu.
Send a Ctrl+Alt+Del to your system using the relevant button or menu entry.
When the boot loader menu appears, press any key to interrupt the countdown.
Edit the default boot loader entry (in memory) to abort the boot process just after all file systems have been mounted, but before control is handed over to systemd, then boot.
Use the cursor keys to highlight the default boot loader entry.
Press e to edit the current entry.
Using the cursor keys, navigate to the line that starts with
linux16.
Press End to move the cursor to the end of the line.
Append rd.break to the end of the line.
Press Ctrl+x to boot using the modified config.
At the switch_root prompt, remount the /sysroot file systemd read-write, then use chroot
to go into a chroot jail at
/sysroot.
switch_root:/#mount -o remount,rw /sysrootswitch_root:/#chroot /sysroot
Change the root password back to redhat.
sh-4.2#echo redhat | passwd --stdin root
Configure the system to automatically perform a full SELinux relabel
after boot. This is necessary since the passwd
tool re-created the /etc/shadow file without an
SELinux context.
sh-4.2#touch /.autorelabel
Type exit twice to continue booting your system as
normal. The system will run an SELinux relabel, then reboot again by
itself.
Verify your work by running the following command:
[student@serverX ~]$lab rootpw grade