首页 > 系统服务 > 详细

ubuntu cloud image ssh

时间:2018-03-17 23:16:00      阅读:442      评论:0      收藏:0      [点我收藏+]

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

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下

root@cic-1:~# openstack keypair create --public-key ~/.ssh/id_rsa.pub mykey
root@cic-1:~# 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

root@cic-1:~# ip netns list
qdhcp-b56652f9-5f3d-4a67-97e0-d399d2aa4cd0 #id=network uuid, net172

ip netns exec qdhcp-b56652f9-5f3d-4a67-97e0-d399d2aa4cd0 ssh ubuntu@x.x.x.x #instance IP

 

ubuntu cloud image ssh

原文:https://www.cnblogs.com/marcoxu/p/8593082.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!