Building an Ubuntu cloud-init template on Proxmox
A template with the guest agent baked in and predictable first boots.
What it’s for
Section titled “What it’s for”A Proxmox template whose clones report their address, shut down cleanly and freeze filesystems for backups.
What you need
Section titled “What you need”- Proxmox VE 9
libguestfs-toolson the Proxmox host
- Download the Ubuntu cloud image and check its SHA-256. Work on a copy:
cp resolute-server-cloudimg-amd64.img work.img- Bake in the guest agent, update packages, and clear the machine ID:
virt-customize -a work.img \ --update \ --install qemu-guest-agent \ --run-command "systemctl enable qemu-guest-agent" \ --truncate /etc/machine-id- Create the VM, import the disk, add a cloud-init drive, set
--agent enabled=1, and convert it to a template (ID 9000 or similar). - For quick throwaway clones, add
--ciupgrade 0so first boot doesn’t upgrade packages.
Check it worked
Section titled “Check it worked”qm agent <id> pingsucceeds a few seconds after a clone starts.- SSH answers right away on clones with
ciupgrade 0.
Traps seen
Section titled “Traps seen”- Stock Ubuntu cloud images don’t include
qemu-guest-agent. Enabling the agent in Proxmox only adds the host side. ciupgrade: 1(the default) upgraded openssh-server on first boot, and SSH refused connections for about 15 seconds.cloud-init status --longcan saydegraded donebecause of a deprecation warning about theuserkey that Proxmox writes.errors: []means it’s fine.- Use
qm guest execto look inside a VM when SSH isn’t up.
Where this came from
Section titled “Where this came from”- SSH refused connections right after the VM’s first boot (2026-10-19)
- Reviewing phases 1 to 3 (2026-10-20)