If you’ve paid attention to most Linux distros' download pages, you must have noticed that many of them offer something called cloud images. Cloud images are usually qcow2 images that have a Linux distro pre-installed.
But, once you launch the image you’ll find that you need a root password to log in.
Is there a default password? No, not really. These images are specifically built for cloud providers like AWS who run their own modifications on top of them.
But that doesn’t mean that they aren’t usable directly from, say, QEMU for example.
Earlier, I used to use a program called guestfish to modify the root password that is set in the qcow2 image. But there exists a better and faster method.
Note: Make sure you have libvirt installed, since the command used below will essentially spin up a VM to change the root password.
Let’s install the required package first, which for me (Fedora) is named as libguestfs-tools-c.
On Fedora, the command to install the package is :
sudo dnf install libguestfs-tools-c
Then, we can go ahead and modify the root password for a qcow2 image by invoking the command below :
sudo virt-customize -v -a <your-qcow2-image> --root-password password:<your-password-here>