openstack flavor create
\
--vcpus 2
--ram 4096
--disk 40\
--public
m1.custom
适用于支持 cloud-init 的镜像(如 Ubuntu、CentOS 等官方镜像)。
cloud-init
openstack image create \
--disk-format qcow2 \
--container-format bare \
--file ubuntu.qcow2 \
--property hw_qemu_guest_agent=yes \
--property os_require_quiesce=yes \
--property user_data="$(cat user-data.yaml)" \
ubuntu-with-password
user-data.yaml
#cloud-config password: 您的密码 chpasswd: expire: false ssh_pwauth: true
启动实例后,直接通过 root 和设置的密码登录:
root
ssh root@<实例IP>
virt-customize
适用于不支持 cloud-init 的镜像(如自定义镜像)。
libguestfs-tools
sudo apt install libguestfs-tools # Debian/Ubuntu sudo yum install libguestfs-tools # CentOS/RHEL
virt-customize -a your-image.qcow2 \
--root-password password:YourNewPassword
--file your-image.qcow2 \
--public \
custom-image-with-password