修改qcow2镜像密码

发布时间 2023-03-30 17:03:11作者: leiuk
修改qcow2镜像密码
1、安装libvirtd
# Ubuntu $ apt install -y qemu-kvm libvirt-bin bridge-utils virt-manager # CentOS

$ yum install -y qemu-kvm libvirt virt-install bridge-utils

 

2、启动libvirtd服务

systemctl start libvirtd

 

3、生成密码
[root@192 home]# openssl passwd -1 123456

$1$Nnv2QHyN$qu2bZyh7ef7xQJZnRtDSJ

 

4、加载qcow2文件
[root@192 system]# guestfish --rw -a CentOS-7-x86_64-GenericCloud-1805.qcow2 Welcome to guestfish, the guest filesystem shell for editing virtual machine filesystems and disk images. Type: ‘help’ for help on commands      ‘man’ to read the manual      ‘quit’ to quit the shell

><fs>

 

5、修改密码
><fs> run 100% ⟦▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒▒⟧ 00:00 ><fs> list-filesystems /dev/sda1: xfs ><fs> mount /dev/sda1 / ><fs> vi /etc/shadow  #替代root的秘密,利用前面openssl生成的密码 ><fs> quit