zoukankan      html  css  js  c++  java
  • ubuntu cloud image ssh

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

    KVM下

    用的image xenial-server-cloudimg-amd64-disk1.img,format=qcow2

    apt-get install cloud-utils

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

    img文件不能放在/root下,会提示没有权限,可以放在/opt/或kvm image的默认目录

    在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

  • 相关阅读:
    Xah Lee Web 李杀网
    About Unixstickers
    Amazon.com: NEW VI AND VIM EDITOR KEYBOARD STICKER: Office Products
    Company Story | Vistaprint
    8月30号周五香港接单ING~~化妆品只加10元!!!!!!
    贝佳斯绿泥多久用一次?_百度知道
    贝佳斯绿泥_百度百科
    [PHP]利用MetaWeblog API实现XMLRPC功能
    The tempfile module
    20.23. xmlrpclib — XML-RPC client access — Python v2.7.5 documentation
  • 原文地址:https://www.cnblogs.com/marcoxu/p/8593082.html
Copyright © 2011-2022 走看看