ubuntu cloud image ssh

Posted marcoxu

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ubuntu cloud image ssh相关的知识,希望对你有一定的参考价值。

###############

KVM下

用的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格式的

在create VM的时候将上面这个cloud.img作为cdrom mount到VM上
virt-install --virt-type kvm --name host-1 --ram 1024 --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
然后可以给root设置密码,enable ssh password login

 

#############

openstack下

[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的主要内容,如果未能解决你的问题,请参考以下文章

在Openstack中使用Ubuntu的Cloud images如何设置密码

ubuntu server cloud img username password

openstack 官方镜像qcow2 下载和修改密码

Openstack 之 使用disk-image-builder(DIB)制作镜像

ubuntu18.04 devstack openstack stein部署

ubuntu18.04 devstack train安装 python3