← Back to all articles

Creating a Proxmox VM Template with Cloud-Init

Step-by-step guide to building a reusable Proxmox VM template with Cloud-Init — from base Ubuntu setup and hardening to cloning production-ready VMs in seconds.

Updated 4 min read

Spinning up VMs manually every time is slow and error-prone. A better approach is to build a golden image once — hardened, updated, and pre-configured — then stamp out identical clones in seconds using Cloud-Init. This guide walks through the full process on Proxmox VE.

1. Create and prepare the base VM

Create a new VM in Proxmox as usual and install Ubuntu Server (LTS recommended).

Once the OS is installed, apply your standard hardening and configuration:

  • Install required packages (e.g. Docker, monitoring agents)
  • Add your SSH public keys
  • Disable SSH password authentication
  • Configure users, sudo, and firewall rules

This is the base image every future clone will inherit, so get it right once. For a detailed walkthrough of SSH key setup and hardening, see Ubuntu SSH Key Authentication and Hardening.

Ubuntu SSH Key Authentication and Basic Hardening

Set up SSH key-based login on Ubuntu, disable password authentication, and enable passwordless sudo — essential hardening for any server or VM template.


2. Install the Proxmox Guest Agent

The QEMU Guest Agent enables Proxmox to communicate with the VM for proper shutdown, IP reporting, and filesystem freeze/thaw during backups.

sudo apt-get update
sudo apt-get install -y qemu-guest-agent
sudo systemctl enable qemu-guest-agent
sudo systemctl start qemu-guest-agent

Then enable it in the Proxmox UI:

VM → Options → QEMU Guest Agent → Enabled


3. Update the system and reboot

Apply all pending updates before sealing the image:

sudo apt-get update
sudo apt-get upgrade -y
sudo reboot

4. Install Cloud-Init

Cloud-Init handles per-instance configuration on first boot — hostname, SSH keys, networking, and user setup.

sudo apt-get install -y cloud-init

5. Remove SSH host keys

Each VM needs unique SSH host keys. Removing them from the template ensures Cloud-Init regenerates fresh keys for every clone.

sudo rm /etc/ssh/ssh_host_*

6. Clean the image and power off

Run the final cleanup sequence to remove instance-specific data:

sudo apt clean
sudo apt autoremove
sudo cloud-init clean
sudo cloud-init clean --machine-id
sudo poweroff

7. Add a Cloud-Init drive in Proxmox

Add a Cloud-Init drive to the VM in the Proxmox UI. The drive type depends on your firmware:

In the Proxmox web UI: select the VM → HardwareAddCloudInit Drive → choose your storage and the correct bus type.

  • OVMF (UEFI): Add a SCSI Cloud-Init drive
OVMF (UEFI) — SCSI Cloud-Init drive
  • SeaBIOS: Add an IDE Cloud-Init drive
SeaBIOS — IDE Cloud-Init drive

8. Configure Cloud-Init defaults

Open the Cloud-Init section of the VM and set default values that every clone should inherit.

OptionExample value
Userusername
Password(leave empty — use SSH keys)
DNS domainexample.localdomain
DNS servers1.1.1.1 8.8.8.8
SSH public keyssh-ed25519 AAAA... user@host
IP Config (net0)DHCP

After setting the values, click Regenerate Image to write the configuration to the Cloud-Init drive.


9. Convert the VM to a template

With the VM powered off and Cloud-Init configured, convert it to a template:

  1. Select the VM in the Proxmox sidebar
  2. Right-click (or use the top-right menu)
  3. Click Convert to template

10. Clone the template

To deploy a new VM from the template:

  1. Right-click the template in the Proxmox sidebar
  2. Click Clone
  3. Choose Full Clone (independent copy) or Linked Clone (shares base disk, saves space)
  4. Set a name and target storage

11. Final Cloud-Init configuration

Open the cloned VM and go to the Cloud-Init section. Override the per-instance values:

OptionExample value
Userusername (or keep inherited)
DNS domainprod.localdomain companyname.com
DNS servers1.1.1.1 8.8.8.8
SSH public key(keep inherited or add a different key)
IP Config (net0)ip=10.0.1.50/24,gw=10.0.1.1 (static) or DHCP

Click Regenerate Image to apply the changes.


12. Power on

Start the cloned VM. Cloud-Init runs on first boot and applies your configuration — setting the hostname, injecting SSH keys, configuring networking, and regenerating SSH host keys.

Your new VM is ready to use, identical to the golden image but with its own unique identity.

Search articles
esc to close