###############
Under KVM
Using the image Xenial-server-cloudimg-amd64-disk1.img,format=qcow2
Cat > Hostpass <<eof
#cloud-config
Password:root123
CHPASSWD: {Expire:false}
Ssh_pwauth:true
Cloud-localds cloud.img hostpass #用hostpass文件生成cloud. img
Qemu-img Info cloud.img #raw格式的
When you create the VM, use the above cloud.img as CDROM mount to the VM
Virt-install--virt-type KVM--name host-1--ram 1024x768--vcpus 1--import \
--DISK/VAR/LIB/LIBVIRT/IMAGES/HOST-1/XENIAL-SERVER-CLOUDIMG-AMD64-DISK1.IMG,FORMAT=QCOW2 \
--disk/var/lib/libvirt/images/host-1/cloud.img,device=cdrom \
--network bridge=br-mgmt,model=e1000,mac=52:54:00:33:22:11 \
--network bridge=br-leaf1-link3,model=e1000 \
--network bridge=br-leaf2-link3,model=e1000 \
--graphics none \
--noautoconsole
Virsh host-1
Ubuntu/root123
You can then set the password for root, enable SSH password login
#############
OpenStack under
[Email protected]:~# openstack keypair Create--public-key ~/.ssh/id_rsa.pub MyKey
[Email protected]:~# openstack keypair List
+-------+-------------------------------------------------+
| Name | Fingerprint |
+-------+-------------------------------------------------+
| MyKey | aa:28:b1:45:24:be:c8:4a:7f:23:7a:49:e5:ad:c8:2e |
+-------+-------------------------------------------------+
OpenStack Server Create--flavor m1.small--image <image name>--nic net-id=<nic uuid>--security-group allow_ IPv4--key-name MyKey--user-data cloud-config.txt instance-test2
[Email protected]:~# IP Netns List
Qdhcp-b56652f9-5f3d-4a67-97e0-d399d2aa4cd0 #id =network uuid, net172
IP netns exec qdhcp-b56652f9-5f3d-4a67-97e0-d399d2aa4cd0 ssh [email protected] #instance IP
Ubuntu Cloud Image ssh