Cloud image镜像linux使用virt-customize工具修改密码
sudo yum install libguestfs-tools
或
sudo apt install libguestfs-tools
或
sudo dnf install libguestfs-tools
第二步,设定一个固定密码
sudo virt-customize -a CentOS-7-x86_64-GenericCloud-1703.qcow2 --root-password password:passw0rd
结束。
sudo virt-customize -a CentOS-7-x86_64-GenericCloud-1703.qcow2 --root-password random[ 0.0] Examining the guest ...
[ 11.2] Setting a random seed
[ 11.2] Setting passwords
virt-customize: Setting random password of root to 132Tfe6cfCCr8Pv8
[ 12.2] Finishing off
这一步还可以是这样:安装或删除package,甚至同时设置自己的SSH key
sudo virt-customize -a CentOS-7-x86_64-GenericCloud-1703.qcow2 --install epel-release --ssh-inject centos:string:"ecdsa-sha2-nistp256 AAAAE2VjZHNhLXNoYTItbmlzdHAyNTYAAAAIbmlzdHAyNTYAAABBBKCqX6EZIrGHoGaMII4QAqr0QC72t+Kg/c5ZIRNTMb6Q+BwzejQgjhBTXeyPnp0rfE9XI4pTxkZqAUOGSK9Bfqg= smiller@bruckner"
PermitRootLogin yesPasswordAuthentication yes
2. 重启sshd
目录 返回
首页