ssh-import-id (<module 'cloudinit.config.cc_ssh_import_id' from '/usr/lib/python3/dist-packages/cloudinit/config/cc_ssh_import_id.py'>) failed
ci-info: +++++++++++++++++++++++++++++++++Authorized keys from /home/ubuntu/.ssh/authorized_keys for user ubuntu+++++++++++++++++++++++++++++++++
ci-info: +---------+-------------------------------------------------------------------------------------------------+---------+----------------+
ci-info: | Keytype | Fingerprint (sha256) | Options | Comment |
ci-info: +---------+-------------------------------------------------------------------------------------------------+---------+----------------+
ci-info: | ssh-rsa | 33:11:22:d7:b1:f9:83:3b:b8:94:9f:f3:33:33:33:33:12:12:8f:d4:34:2e:60:12:12:12:ae:12:12:12:d4:60 | - | milton@somewhe |
ci-info: +---------+-------------------------------------------------------------------------------------------------+---------+----------------+
使用显示的IP, 以及之前配置的私钥就可以直接登录
一个完整的新虚机安装流程
Copy and resize image to 50GB
sudo cp /data/backup/CentOS-7-x86_64-GenericCloud.qcow2c vm_centos7a.qcow2
qemu-img info vm_centos7a.qcow2
sudo qemu-img resize vm_centos7a.qcow2 50G
# double check
qemu-img info vm_centos7a.qcow2
Prepare 2 files
metadata.yaml
instance-id: iid-local02
local-hostname: vm_u2204b
- change
instance-id
to a different id
- change
local-hostname
to the virtual machine hostname
user-data.yaml
The following config will
- create default users and
- create a additional sudo user milton
- enable password login
#cloud-config
users:
- default
- name: milton
groups: [sudo]
sudo: ALL=(ALL) NOPASSWD:ALL
shell: /bin/bash
lock_passwd: false
plain_text_passwd: ubuntu
chpasswd:
expire: False
ssh_pwauth: True
-default
is the default cloud-init users (by default it is user named ubuntu
)
users - name
your user name
users - shell
must specified, or no shell presents
users - lock_passwd
set it to false to allow login
users - plain_text_passwd
use this to set the user password
chpasswd
and ssh_pwauth
seed.img
cloud-localds seed.img user-data.yaml metadata.yaml
copy the ubuntu cloud image to vms folder, and resize it to 50GB
cd /vms/
sudo cp /data/backup/ubuntu-22.04-minimal-cloudimg-amd64.img vm_u2204b.img
qemu-img info vm_u2204b.img
sudo qemu-img resize vm_u2204b.img 50g
# recheck
qemu-img info vm_u2204b.img
Then start to install
virt-install --name vm_u2204b --vcpus 2 --memory 4096 --graphics none --import --os-variant ubuntu22.04 --network bridge=br0,model=virtio --disk /vms/vm_u2204b.img --disk /vms/seed.img
参考