Table of Contents
This updated guide examines Use Guestfish to Reset the Forgotten Root Password for the and organizes the essential facts, background, and practical takeaways in clear American English.
Responsible-use note: Apply security techniques only to systems you own or are explicitly authorized to test.
Prepare LAB lesson
- On a VMware environment, use a CentOS 7 virtual machine with KVM installed.
- Create a CentOS 7.0 virtual machine with qcow2 format
Proceed to set the root password
Step 1: Install Guestfish
yum install libguestfs-tools -y
Step 2: Shutdown the virtual machine

virsh shutdown tên_máy_?o
Step 3: Reset, change the root password using Guestfish
Note: First create a new root user password by typing the following command and then using the encrypted password to change.
openssl passwd -1 pass_m?i

Then run the following command, for the Centos7 virtual machine:
guestfish --rw -a /var/lib/libvirt/images/centos7.0.qcow2

Next use the following commands
> launch > list-filesystems #li?t kê các phân vùng /dev/sda1: xfs /dev/centos/root: xfs /dev/centos/swap: swap > mount /dev/centos/root / #l?u ý l?a ch?n mount vào phân vùng c?a h? th?ng có ch?a th? m?c /etc. > vi /etc/shadow #ch?nh s?a file shadow

For example: The same for ubuntu virtual machines

After running the vi / etc / shadow command, fix the encrypted pass at root with the new encrypted pass from the openssl command above and save it:

Then exit Guestfish:
> quit
Step 4: Open the virtual machine with virt-manager and enter the new password
So you have finished resetting the forgotten root password for the virtual machine in qcow2 format on KVM.
FAQ
What is Use Guestfish to Reset the Forgotten Root Password for the about?
It provides a structured overview of kvm, explains the main context, and highlights practical takeaways for readers.
Why does this topic matter?
Understanding the main concepts helps readers evaluate the issue, avoid common mistakes, and make better-informed decisions.
How should readers use this information?
Use the guidance as a practical starting point, confirm details that may have changed, and follow current product, safety, or security recommendations.
Reader Comments 0
Sign in with email or Google to join the discussion.