Friday, 1 November 2019

How to Changing/Reset the root password on the CentOS 7 qcow2 Image (virt-customize)



"virt-customize" provide a feature to customize a file system and its configuration data of a qcow2 format images.

This article describes How to Change/Reset the password of the CentOS 7 qcow2 Image

Step 1. Prerequisites: Install libguestfs-tools by issuing the following command:

[root@linuxcnf ~]# yum install libguestfs-tools
Loaded plugins: fastestmirror
..................
Installed:
  libguestfs-tools.noarch 1:1.40.2-5.el7_7.2

Dependency Installed:
  alsa-lib.x86_64 0:1.1.8-1.el7                                        attr.x86_64 0:2.4.46-13.el7
..................
    usbredir.x86_64 0:0.7.1-3.el7                                        yajl.x86_64 0:2.0.4-4.el7

Dependency Updated:
  cryptsetup-libs.x86_64 0:2.0.3-5.el7    device-mapper.x86_64 7:1.02.158-2.el7_7.2    device-mapper-libs.x86_64 7:1.02.158-2.el7_7.2

Complete!
[root@linuxcnf ~]#

Step 2. Change the Password: Now run the following command virt-customize to change the password of root user. Replace the password with some strong password for root user.

[root@linuxcnf ~]# virt-customize -a /var/lib/libvirt/images/CentOS-7-x86_64-GenericCloud-1907.qcow2 --root-password password:password
[   0.0] Examining the guest ...
[  23.8] Setting a random seed
[  24.1] Setting passwords
[  36.4] Finishing off
[root@linuxcnf ~]#

Done!!! Now try to login with the given password.

No comments:

Post a comment