The following code can be used to make Ubuntu cloudimg for use on a Debian 7.2 (wheezy) machine:
apt-get install pwgen apt-get install genisoimage git clone -b master https://git.launchpad.net/cloud-utils printf "#cloud-config\n" > user-data printf "password: 'pwgen 8 1'\nchpasswd: { expire: False }\nssh_pwauth: True\n" >> user-data ./cloud-utils/bin/cloud-localds user-data.img user-data
Afterwards, you should run an image like this from the tmux window to make sure that it continues to work even if you log out:
kvm -m 2048 -smp 2 -hda ubuntu-18.10-server-cloudimg-amd64.img -hdb user-data.img -net nic -net user,hostfwd=tcp::1810-:22 -nographic
You can then log in as the ubuntu user and the password generated in user-data . Login can be either through a serial console printed by kvm (which will usually be quite slow even if you have an ssh connection on top of it) or through ssh with ssh ubuntu@localhost -p1810 . The ubuntu user, by default, accesses the sudo password as the root user.
PS I also tried to play with the addition of ssh-authorized-keys , but the cloud-config format seems very fragile and at the top level it is simply ignored, while at the user users: level users: as shown below, the whole ubuntu user seems to break (at least least part of the password). Here is the code to get the keys in a format that is potentially legible for the cloud configuration:
printf "users:\n - name: ubuntu\n ssh-authorized-keys:\n" >> user-data cat ~/.ssh/id_rsa.pub ~/.ssh/authorized_keys | sed 's/^/ - /g' >> user-data
(Note that password , apparently, may be an invalid field for the users specification, since instead it has a passwd hash code, so all this violates the previous code, because now user Ubuntu is created without a password.)
cnst
source share