Statement
This document is only for learning and exchange, please do not use for other commercial purposes
Author: Chaoyang _tony
E-mail:linzhaolover@163.com
Create date:2016-10-18 13:10:37
Last change:2016-10-18 16:10:44
Reprint please indicate the source: Http://blog.csdn.net/linzhaolover
Now the use of virtual machine KVM is very popular, in order to more differentiated environment, each person may have a lot of KVM, this number will inevitably have an image password will forget, I believe many people will use kernel single user mode into the system to modify the secret, but, Since Rhel7 and ubuntu14.04, have been certified to enter a single user, but also need a password, which does increase security. The following is a brief introduction to modifying the files in image directly through the Libguestfs-tools tool without starting the KVM. View KVM List
# Virsh list--all
Id Name State
----------------------------------------------------
- rhel7.0 shut off
- rhel7.0-cloud shut off
- ub12-clear shut off
- Ub14.04-clear shut off
- ub14.04-clear-clone shut off
- ubuntu14.04 shut off
rhel7.0 This is the KVM installation that I need to change my password libguestfs-tools
sudo yum install libguestfs-tools # fedora/rhel/centos
sudo apt-get install libguestfs-tools # debian/ Ubuntu
After the installation is complete, a lot of VIRT commands are added, this time we mainly use Virt-edit to generate a new cipher string
# OpenSSL passwd-1-salt ' hello ' ' 123456 '
$1$hello$zwmhcpcg.i1xifvjdarkc1
OpenSSL is a cryptographic tool,-1 refers to ordinary encryption, hello for key, 123456 is the password, the following is the generated password string, so we just have to do the corresponding replacement wine can be
Encrypted passwords for Linux systems are usually stored in/etc/shadow files
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:::
Modify system root account password
Virt-edit-d Rhel7.0/etc/shadow
Depending on the size of the KVM image, usually open in two minutes, we just replace the corresponding part of the root of the wine can be
Root:$1$btprdwwf$lpjuzmgthw.hyfccl0/lk.:16804:0:99999:7:::
replacement for
ROOT:$1$HELLO$ZWMHCPCG.I1XIFVJDARKC1 : 16541:0:99999:7::
Save exit, start KVM, you can enter with the latest password, current password is 123456
Http://libguestfs.org/virt-edit.1.html