Use Guestfish to reset the forgotten root password for the virtual machine in qcow2 format on KVM
Suppose you set a root password for the virtual machine on KVM, but forgot it. So, how to gain root access? Please use Guestfish to reset the root password in qcow2 format on KVM. Here is what you need to prepare and do.
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.
You should read it
- How to fix the error of creating Password Reset Disk on Windows
- How to reset the password for sudo in Debian
- How to reset Admin password on Windows with Sticky Keys
- 3 ways to simply retrieve the Momo password
- Create Windows Password Reset Disk on Windows 7 with USB Flash Drive
- How to Use a Password Reset Disk (Windows)
- How to change Snapchat password on phone and computer
- How to Reset Admin Password on Mac OS X
May be interested
- How to Reset Windows 7 Passwordif you forget your windows 7 password, you will have to reset your user account password to log in. windows 7 passwords can be reset by your network administrator if your computer is in a domain, or can be reset using a password reset disk if your computer is in a homegroup or workgroup. this article will teach you to reset windows 7 password in both ways.
- How to Use a Password Reset Disk (Windows)if you forget your password, you can log on to the computer by using a new password you created using the password reset wizard and your password reset disk. in the welcome to windows dialog box, press ctrl+alt+delete and log off.
- How to Change Root Password in Linuxthis tipsmake article shows how to change the root password in the linux operating system, applicable in cases where you remember your current password or cannot remember your root password.
- How to fix the error of creating Password Reset Disk on Windowsif you forget your computer login password, you can use password reset disk to create a new password. but what if this option fails?
- How to use Password Reset Disk to reset Windows password?in previous articles, network administrator showed you how to create a password reset disk on windows 7/8/10. in the following article, network administrator will guide you how to use password reset disk to reset windows password.
- Fix some errors when using Password Reset Wizardwhen you forget your windows computer login password, you can use the password reset wizard to create a new login password. however, in some fields when using password reset wizard, some users encounter an error: an error occurred while the wizard was attempted to set the password for the user account.
- How to Change the Root Password in Linuxthis wikihow teaches you how to change the linux root password if you have the current password or if you don't have access to the current root password. open a terminal window. to do so, press ,https://help.ubuntu.com/community/usingthe...
- How to Change Your Apple ID Passwordthis wikihow teaches you how to change your apple id password on a computer or on your iphone. if you've forgotten your apple id password, you'll need to reset your apple id password instead. open the apple id website. go to...
- How to Reset a Lost Admin Password on Mac OS Xif you're logged into your mac with your apple id account, you may be able to use it to reset your admin password. if you aren't you can use recovery mode on your mac to open the reset password utility. you can also reset a password with...
- How to retrieve a Tik Tok password when it is losttik tok password can be retrieved via email or via phone number registered tik tok account, when users forget or lose the password tik tok.