场景一: kvm 虚拟机忘记密码无法登陆 解决方法: 1.kvm虚拟机中安装了qemu-guest-agent,使用agent修改 2.使用工具virt-edit修改 准备密码串 openssl passwd -1 -salt 'hello' '123456' linux的加密密码存在文件/etc/shadow root:$1$bTPRDWwf$LpjUZmGTHw.hYFccl0/lK.:16804:0:99999:7::: bin:*:15937:0:99999:7::: daemon:*:15937:0:99999:7::: adm:*:15937:0:99999:7::: lp:*:15937:0:99999:7::: sync:*:15937:0:99999:7::: shutdown:*:15937:0:99999:7::: 关闭kvm虚拟机 virsh shutdown rhel7.0 (virt-edit方式) virt-edit -d rhel7.0 /etc/shadow 替换 root:$1$bTPRDWwf$LpjUZmGTHw.hYFccl0/lK.:16804:0:99999:7::: 更换为 root:$1$hello$ZwmhCpcG.I1XIfVjdarKc1:16804:0:99999:7::: 保存退出 重启kvm虚拟机 virsh start rhel7.0 (agent方式) 虚拟机内安装 yum install qemu-guest-agent systemctl start qemu-guest-agent virsh set-user-password rhel7.0 --user root --password 123 virsh domifaddr rhel7.0 --source agent



