码迷,mamicode.com
首页 > 系统相关 > 详细

ubuntu cloud image ssh

时间:2018-03-17 23:22:04      阅读:482      评论:0      收藏:0      [点我收藏+]

标签:密码   ipv4   raw   none   stp   dhcp   span   console   type   

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

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

标签:密码   ipv4   raw   none   stp   dhcp   span   console   type   

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

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!