---
title: How to Create Reusable VM Templates with Cloud-Init on Proxmox VE
url: https://docs.vultr.com/how-to-create-reusable-vm-templates-with-cloud-init-on-proxmox-ve
description: Build a reusable Cloud-Init VM template from an Ubuntu cloud image on a Vultr Bare Metal server running Proxmox VE, then clone VMs with SSH keys and networking.
publish_date: 2026-11-27T16:43:27.079335Z
last_updated: 2026-11-27T18:28:01.520897Z
author: Ayomide olofinsawe
header_image: https://lhr1.vultrobjects.com/docs-main-doc-assets-1/2686/9c0aecc2-2aff-4b2e-8c52-a58ac7ce4c94.png
---

> Index of every Vultr Docs page in markdown: https://docs.vultr.com/llms.txt

A template on [Proxmox Virtual Environment (Proxmox VE)](https://www.proxmox.com/en/products/proxmox-virtual-environment/overview) is a master copy of a configured virtual machine (VM) that you clone to create new VMs without building each one from scratch. [Cloud-Init](https://cloud-init.io/) is an open-source tool that configures a VM on its first boot. It applies the user, Secure Shell (SSH) key, and network settings you provide, so a new clone is ready to log in to once its first boot finishes.

This guide explains how to convert an Ubuntu cloud image into a reusable VM template on a Vultr Bare Metal server running Proxmox VE. It covers configuring Cloud-Init with your SSH key, installing the QEMU guest agent, setting up a private network for the VMs, and cloning the template to deploy VMs.

## Prerequisites

Before you begin:

* Have access to a [Vultr Bare Metal server](https://www.vultr.com/products/bare-metal/).
* [Install Proxmox VE](https://docs.vultr.com/how-to-install-proxmox-ve-on-a-vultr-bare-metal-server) on the server.
* Create a [non-root user with sudo privileges](https://docs.vultr.com/how-to-create-a-sudo-user-in-linux).

## Understanding Cloud-Init and VM Templates

Cloud images are operating system disks that distributions typically publish with Cloud-Init included. On a VM's first boot, Cloud-Init reads the settings that Proxmox VE provides for it, such as the user, SSH key, hostname, and network, and applies them.

A clone comes together in this order:

1. You configure a VM once and convert it to a template, which you clone to create new VMs. The template stores the installed system and the default settings, such as the user and SSH key.
1. Each clone copies the template and gets its own settings, such as its hostname and address.
1. When the clone starts for the first time, Cloud-Init applies the combined settings.

## Download a Cloud Image

This guide uses the Ubuntu 24.04 cloud image. Ubuntu publishes it along with a checksum file listing the correct checksum for each image.

1. Download the Ubuntu 24.04 (`noble`) cloud image from the [Ubuntu cloud images site](https://cloud-images.ubuntu.com/noble/current/).

    ```console
    $ wget https://cloud-images.ubuntu.com/noble/current/noble-server-cloudimg-amd64.img
    ```

1. Download the checksum file that Ubuntu publishes for the image.

    ```console
    $ wget https://cloud-images.ubuntu.com/noble/current/SHA256SUMS
    ```

1. Verify the image against its checksum.

    ```console
    $ sha256sum --ignore-missing -c SHA256SUMS
    ```

    The `SHA256SUMS` file lists checksums for several images. The `--ignore-missing` option checks only the image you downloaded. Verify that the output shows `noble-server-cloudimg-amd64.img: OK`. A match confirms that the download is intact.

## Create a VM from the Cloud Image

A new VM has no operating system. Because the cloud image already contains an installed one, you import it as the VM's disk and skip the installer.

1. Check which VM IDs the server already uses.

    ```console
    $ sudo qm list
    ```

    Each ID is a unique number from 100 to 999999999. A new installation has no VMs, so the list is empty.

1. Check which container IDs the server already uses.

    ```console
    $ sudo pct list
    ```

    A new installation has no containers, so the list is empty. This guide uses `9000` as the template ID. If `9000` appears in either list, choose another ID and replace it in the remaining commands.

1. Create the VM.

    ```console
    $ sudo qm create 9000 --name ubuntu-2404-template --memory 2048 --cores 2 --net0 virtio,bridge=vmbr0 --ostype l26
    ```

    This command creates an empty VM with 2048 MiB of memory, 2 CPU cores, and a network card attached to the `vmbr0` bridge, which is the virtual switch that connects VMs to the server’s network. Every clone inherits these memory and CPU settings by default. You may specify different values if your server’s resources allow.

1. List the VMs.

    ```console
    $ sudo qm list
    ```

    Verify that the output lists VM `9000` with the name `ubuntu-2404-template` and the status `stopped`.

1. List the storage pools that can hold VM disks.

    ```console
    $ sudo pvesm status --content images
    ```

    Verify that the `Name` column lists `local-lvm`. Proxmox VE creates it when you install with the ext4 or xfs filesystem. The output can also list a Directory storage, such as `data1`.

1. Import the cloud image as a disk. Replace `STORAGE` with the name from the `Name` column in the previous step, for example, `local-lvm`.

    ```console
    $ sudo qm disk import 9000 noble-server-cloudimg-amd64.img STORAGE
    ```

    The last line of the output names the new disk, for example, `unused0: successfully imported disk 'local-lvm:vm-9000-disk-0'`. Note the disk name between the quotes. The next step uses it.

1. Attach the imported disk to the VM. Replace `IMPORTED_DISK` with the disk name from the previous step.

    ```console
    $ sudo qm set 9000 --scsihw virtio-scsi-pci --scsi0 IMPORTED_DISK
    ```

1. Set the VM to boot from the disk.

    ```console
    $ sudo qm set 9000 --boot order=scsi0
    ```

    A new VM boots from the network. This command makes it boot from the disk instead.

1. Add a serial port and use it as the display. The cloud image writes its boot messages to a serial port, so this setting lets you see them.

    ```console
    $ sudo qm set 9000 --serial0 socket --vga serial0
    ```

1. Resize the disk. Cloud images ship with a small disk, so resize it before you convert the VM to a template.

    ```console
    $ sudo qm disk resize 9000 scsi0 10G
    ```

    The command sets the disk's total size to 10 GiB. You can choose a different size, as long as it fits in the free space that `sudo pvesm status` shows for the storage. Each clone gets a disk of this size. Cloud-Init grows the root filesystem to use the extra space on the first boot of each clone.

1. Display the VM configuration.

    ```console
    $ sudo qm config 9000
    ```

    Verify that the output includes these values:

    * `scsi0` with the size you set
    * `boot: order=scsi0`
    * `serial0: socket` and `vga: serial0`
    * `net0` with `bridge=vmbr0`

## Attach the Cloud-Init Drive

Cloud-Init reads its settings from a small virtual drive that Proxmox VE attaches to the VM.

1. Add the Cloud-Init drive to the VM. Replace `STORAGE` with the same name that you used in the import command, for example, `local-lvm`.

    ```console
    $ sudo qm set 9000 --ide2 STORAGE:cloudinit
    ```

    The output includes a line such as `ide2: successfully created disk 'local-lvm:vm-9000-cloudinit,media=cdrom'`.

1. Display the VM configuration.

    ```console
    $ sudo qm config 9000
    ```

    Verify that the output includes an `ide2` line that contains `cloudinit`, for example, `ide2: local-lvm:vm-9000-cloudinit,media=cdrom`.

## Set the User and SSH Key

Ubuntu cloud images have no password, so a clone accepts logins only via an SSH key.  Cloud-Init installs a public key for the `ubuntu` user on every clone at first boot. The public key is safe to share, and the matching private key stays on your local computer as the only way to log in.

> [!NOTE]
> You can use a dedicated key pair for the VMs. Use its `.pub` file when you display the public key, and pass its private key to the login command later with the `-i` option.

1. On macOS or Linux, display your public key in a terminal on your local computer. If your key file has a different name, use its `.pub` file.

    ```console
    $ cat ~/.ssh/id_ed25519.pub
    ```

    The output is one line that starts with the key type, such as `ssh-ed25519`. Copy the whole line.

1. On Windows, display your public key in PowerShell on your local computer. If your key file has a different name, use its `.pub` file.

    ```console
    > Get-Content ~\.ssh\id_ed25519.pub
    ```

    The output is one line that starts with the key type, such as `ssh-ed25519`. Copy the whole line.

1. Save the public key to a file on the server. Replace `PUBLIC_KEY` with the line you copied.

    ```console
    $ cat > ~/ubuntu-template.pub << 'EOF'
    PUBLIC_KEY
    EOF
    ```

1. Set the username and the SSH key on the VM.

    ```console
    $ sudo qm set 9000 --ciuser ubuntu --sshkeys ~/ubuntu-template.pub
    ```

    The `--ciuser` option sets the username that receives the key. The `--sshkeys` option reads the file and stores the key in the VM configuration. The VMs have no password, so you log in with your private key.

    > [!WARNING]
    > Make a backup of the private key, because you cannot recover it if you lose it.

1. Display the Cloud-Init user data.

    ```console
    $ sudo qm cloudinit dump 9000 user
    ```

    Verify that the output shows `user: ubuntu` and lists your public key under `ssh_authorized_keys`.

## Install the QEMU Guest Agent

The [QEMU guest agent](https://pve.proxmox.com/pve-docs/chapter-qm.html#qm_qemu_agent) is a service inside a VM that lets Proxmox VE read the VM's IP address, send power commands such as shutdown, and freeze its filesystem during a backup. Ubuntu cloud images do not include it. Cloud-Init installs it on every clone when you give it vendor data, which is a file with settings that Cloud-Init applies in addition to the ones Proxmox VE generates. Proxmox VE stores such files as snippets on a storage that allows them.

1. Check whether the `local` storage allows snippets.

    ```console
    $ sudo pvesm status --content snippets
    ```

    If the `Name` column lists `local`, skip the next two steps. If the output shows only the column headings, no storage allows snippets yet. Continue with the next step.

1. Display the storage configuration.

    ```console
    $ sudo cat /etc/pve/storage.cfg
    ```

    Find the `dir: local` entry and note the types on its `content` line, such as `import,vztmpl,backup,iso`.

1. Add `snippets` to the `local` content types. Replace `CONTENT_TYPES` with the types from the previous step.

    ```console
    $ sudo pvesm set local --content CONTENT_TYPES,snippets
    ```

    The command sets the complete list, so `CONTENT_TYPES` keeps the types that `local` already allows.

1. Create the snippets directory.

    ```console
    $ sudo mkdir -p /var/lib/vz/snippets
    ```

    The `local` storage is a Directory storage at `/var/lib/vz`, and it reads snippets from this folder.

1. Create the vendor data file.

    ```console
    $ sudo tee /var/lib/vz/snippets/vendor.yaml > /dev/null << 'EOF'
    #cloud-config
    packages:
      - qemu-guest-agent
    runcmd:
      - systemctl start qemu-guest-agent
    EOF
    ```

    The `#cloud-config` line marks the file as Cloud-Init configuration. The `packages` list tells Cloud-Init to install the `qemu-guest-agent` package on the first boot of each clone. The agent starts automatically when the VM boots, and the package installs afterward, so the `runcmd` entry starts it immediately after installation. The clone downloads the package through the private network, which gives it internet access.

1. Enable the guest agent on the template and attach the vendor data file.

    ```console
    $ sudo qm set 9000 --agent enabled=1 --cicustom "vendor=local:snippets/vendor.yaml"
    ```

    The `--agent` option enables communication between Proxmox VE and the agent. The `--cicustom` option points the template to the vendor data file. Each clone inherits both settings.

1. Display the VM configuration.

    ```console
    $ sudo qm config 9000
    ```

    Verify that the output includes `agent: enabled=1` and `cicustom: vendor=local:snippets/vendor.yaml`.

## Convert the VM to a Template

Converting the VM turns it into a template that you can clone. Convert it without starting it first.

1. Convert the VM to a template.

    ```console
    $ sudo qm template 9000
    ```

    The output reports that Proxmox VE renamed the VM disk, for example, `Renamed "vm-9000-disk-0" to "base-9000-disk-0" in volume group "pve"`.

1. Display the VM configuration.

    ```console
    $ sudo qm config 9000
    ```

    Verify that the output includes `template: 1`. The disk name in the `scsi0` line now starts with `base-`, for example, `local-lvm:base-9000-disk-0`.

## Configure a Private Network for the VMs

The hosting network assigns a public IP address to the server and does not assign IPv4 addresses to VMs on the public bridge, `vmbr0`. A private network gives the VMs fixed addresses and routes them to the internet through the server. The network uses IPv4 addresses only.

> [!NOTE]
> For a private network where a Dynamic Host Configuration Protocol (DHCP) server assigns addresses, see the Proxmox VE documentation on [setting up a Simple zone with Source Network Address Translation (SNAT) and DHCP](https://pve.proxmox.com/wiki/Setup_Simple_Zone_With_SNAT_and_DHCP).

1. Check which interface has the server's public IP address.

    ```console
    $ ip -br a
    ```

    Verify that the line for `vmbr0`, the default Proxmox VE bridge, shows the server's public IP address.

    > [!NOTE]
    > The commands in this section use `vmbr0`. If the address is on another interface, use that interface in place of `vmbr0`.

1. Check whether the server already has a `vmbr1` bridge.

    ```console
    $ sudo grep vmbr1 /etc/network/interfaces
    ```

    > [!NOTE]
    > If the command prints nothing, continue with the next step. If it prints lines, choose another bridge name, such as `vmbr2`, replace `vmbr1` with it in this section and the clone commands.

1. Back up the network configuration file.

    ```console
    $ sudo cp /etc/network/interfaces /root/interfaces.backup
    ```

1. Add a private bridge named `vmbr1` to the end of the file.

    > [!NOTE]
    > If your network already uses `10.10.10.0/24`, choose another private `/24` range and use its first three numbers in place of `10.10.10` in this step and the remaining commands.

    ```console
    $ sudo tee -a /etc/network/interfaces > /dev/null << 'EOF'
    auto vmbr1
    iface vmbr1 inet static
            address 10.10.10.1/24
            bridge-ports none
            bridge-stp off
            bridge-fd 0
            post-up   iptables -t nat -C POSTROUTING -s '10.10.10.0/24' -o vmbr0 -j MASQUERADE || iptables -t nat -A POSTROUTING -s '10.10.10.0/24' -o vmbr0 -j MASQUERADE
            post-down iptables -t nat -D POSTROUTING -s '10.10.10.0/24' -o vmbr0 -j MASQUERADE
    EOF
    ```

    The bridge gives the VMs a private network address range, `10.10.10.0/24`. The `post-up` line adds a masquerade rule. For traffic leaving via `vmbr0`, the rule replaces a VM's private address with the server's public IP address, so the VMs can reach the internet. It adds the rule only when it is missing, so repeating the reload does not create duplicates.

1. Display the network configuration file.

    ```console
    $ sudo cat /etc/network/interfaces
    ```

    Verify that the `vmbr0` section is unchanged and that the `vmbr1` block appears at the end.

1. Enable packet forwarding so the server can forward traffic between the two bridges.

    ```console
    $ echo 'net.ipv4.ip_forward=1' | sudo tee /etc/sysctl.d/99-ip-forward.conf
    ```

    The command saves the setting for future restarts.

1. Load the setting.

    ```console
    $ sudo sysctl --system | grep ip_forward
    ```

    Verify that the output includes `net.ipv4.ip_forward = 1`.

1. Check the change without applying it.

    ```console
    $ sudo ifreload -a -n -v 2>&1 | grep vmbr1
    ```

    The `-n` option shows what would change without changing it. Verify that the output lists `vmbr1` as one of the interfaces to bring up.

1. Apply the network configuration.

    > [!WARNING]
    > A mistake in the network configuration can disconnect your SSH session. Keep a second SSH session open until you verify the change.

    ```console
    $ sudo ifreload -a
    ```

1. List the bridges.

    ```console
    $ ip -br a | grep vmbr
    ```

    Verify that `vmbr1` has the address `10.10.10.1/24`.

1. List the NAT rules for outgoing traffic.

    ```console
    $ sudo iptables -t nat -S POSTROUTING
    ```

    Verify that the output lists one `MASQUERADE` rule for `10.10.10.0/24`.

1. Check whether the server uses Uncomplicated Firewall (UFW).

    ```console
    $ sudo ufw status
    ```

    If the output starts with `Status: active`, continue with the next step. If the status is `inactive`, skip the next two steps.

1. Allow the traffic of the VMs through UFW. UFW denies routed traffic by default, so VMs on `vmbr1` cannot reach the internet until you allow it.

    ```console
    $ sudo ufw route allow in on vmbr1 out on vmbr0
    ```

1. List the UFW rules for routed traffic.

    ```console
    $ sudo ufw status verbose | grep -i fwd
    ```

    Verify that the output lists two `ALLOW FWD` rules involving `vmbr0` and `vmbr1`, one for IPv4 and one for IPv6.

## Clone and Deploy from the Template

Each clone is a copy of the template with its own ID, name, and address.

1. Get the next unused VM ID and save it in a variable.

    ```console
    $ VMID=$(sudo pvesh get /cluster/nextid)
    ```

    Proxmox VE returns the next ID that no VM or container uses. The next commands use `$VMID`, so you do not type the number.

    > [!NOTE]
    > The variable lasts only for this SSH session, so run the following steps in the same session.

1. Print the value of the variable.

    ```console
    $ echo $VMID
    ```

    Verify that the output is a number, such as `100`.

1. Clone the template.

    ```console
    $ sudo qm clone 9000 $VMID --name ubuntu-vm-$VMID --full
    ```

    The VM name becomes the hostname, for example, `ubuntu-vm-100`. The `--full` option copies the template disk, so the clone does not depend on the template. Without it, Proxmox VE creates a linked clone on `local-lvm`. A linked clone stores only its changes and needs the template disk.

1. Set the network of the clone. The template uses the `vmbr0` bridge, so each clone needs this step.

    ```console
    $ sudo qm set $VMID --net0 virtio,bridge=vmbr1 --ipconfig0 ip=10.10.10.$VMID/24,gw=10.10.10.1
    ```

    The command moves the network card to the private bridge and assigns a fixed address ending in the VM ID. Each VM gets a different address when its ID is between 100 and 254. The gateway, `10.10.10.1`, is the address of `vmbr1` on the server.

1. Start the clone.

    ```console
    $ sudo qm start $VMID
    ```

    On this first start, Cloud-Init runs and applies the user, SSH key, hostname, and address.

1. (Optional) Watch the clone's boot messages on its serial console.

    ```console
    $ sudo qm terminal $VMID
    ```

    The terminal shows the boot messages and the Cloud-Init output. Wait until the console prints `Reached target cloud-init.target - Cloud-init target`. This line means that Cloud-Init finished. Then press `:key_ctrl:` + `:key_o:` to exit the console.

1. Wait for the clone to be ready to log in.

    ```console
    $ for i in $(seq 45); do
        if timeout 2 bash -c "</dev/tcp/10.10.10.$VMID/22" 2>/dev/null; then
          echo "10.10.10.$VMID is ready"
          break
        fi
        sleep 5
      done
    ```

    After you start a clone, it needs time to set itself up. A login attempt before then fails. The command checks every five seconds for up to about five minutes and prints nothing while it waits. Wait until it prints a line such as `10.10.10.100 is ready`, and then continue to the next step. The next step uses that address. If the command ends without printing that line, verify that the output of `sudo qm config 9000` includes the `ide2` line from the Cloud-Init drive step.

1. Open a new terminal on your local computer, and keep the terminal with your SSH session on the server open.

1. Log in to the clone through the server. Replace `USER` with the name of the sudo user that you use to log in to the server, `SERVER_IP` with the public IP address of the server, and `CLONE_ADDRESS` with the address that the previous step printed, for example, `10.10.10.100`.

    ```console
    $ ssh -J USER@SERVER_IP ubuntu@CLONE_ADDRESS
    ```

    The clone is on the private network, so SSH connects to the server first, then to the clone, using your private key.  SSH prompts you in this order:

    1. If the server asks for `USER`'s password, enter it.
    1. The first time, SSH asks you to confirm the clone's fingerprint. Enter `yes`.
    1. If you protect the private key with a passphrase, enter the passphrase.

    > [!NOTE]
    > If you recreate a clone with the same address, SSH reports `REMOTE HOST IDENTIFICATION HAS CHANGED`. Remove the old key using `ssh-keygen -R CLONE_ADDRESS`, then log in again.

    Run the next four steps in the clone.

1. Wait for Cloud-Init to finish.

    ```console
    $ cloud-init status --wait
    ```

    The command returns when Cloud-Init finishes. On the first boot, Cloud-Init upgrades the packages and installs the guest agent. This takes about a minute. Verify that the output shows `status: done`.

1. Display the hostname.

    ```console
    $ hostname
    ```

    Verify that the hostname matches the VM name, for example, `ubuntu-vm-100`.

1. List the network interfaces of the clone.

    ```console
    $ ip -br a
    ```

    Verify that `eth0` shows the address of the clone, for example, `10.10.10.100/24`.

1. Test the connection to the internet.

    ```console
    $ curl -sI https://cloud-images.ubuntu.com | head -n 1
    ```

    Verify that the command prints `HTTP/1.1 200 OK`. The command uses `curl` because UFW can allow `ping` while blocking web traffic.

1. Return to the terminal with your SSH session on the server. Run the remaining steps there.

1. List the origin of the clone's disks. This check applies to the `local-lvm` storage.

    ```console
    $ sudo lvs -o lv_name,origin
    ```

    Verify that the `Origin` column is empty for the clone's disk, for example, `vm-100-disk-0`, so the clone does not depend on the template. A linked clone lists `base-9000-disk-0` there.

1. Query the guest agent for the clone's network interfaces.

    ```console
    $ sudo qm guest cmd $VMID network-get-interfaces | grep '"ip-address"'
    ```

    Verify that an `ip-address` field shows the address of the clone, for example, `10.10.10.100`.

1. Deploy more VMs with a loop. Each pass picks the next unused ID, so every VM gets a different name and address. Use one number for each VM you want, for example, `1 2 3 4 5`.

    ```console
    $ for i in 1 2 3; do
        NEW_ID=$(sudo pvesh get /cluster/nextid)
        sudo qm clone 9000 $NEW_ID --name ubuntu-vm-$NEW_ID --full
        sudo qm set $NEW_ID --net0 virtio,bridge=vmbr1 --ipconfig0 ip=10.10.10.$NEW_ID/24,gw=10.10.10.1
        sudo qm start $NEW_ID
      done
    ```

    The loop stores each ID in `NEW_ID`, so `$VMID` keeps the ID of the first clone.

1. List the VMs.

    ```console
    $ sudo qm list
    ```

    Verify that the output lists the new VMs as `running`. The address of each VM is `10.10.10.` followed by its ID.

## Conclusion

You have created a reusable VM template from an Ubuntu cloud image on Proxmox VE. The template carries a Cloud-Init drive with your user and SSH key and points to a vendor data file that installs the QEMU guest agent. The private network connects the clones to the internet through the server. Each clone you deploy applies its settings on first boot and is ready to log in to once Cloud-Init finishes. You can now install your own software on the clones, such as a web server or a database, and reach it from the server over the private network. For more information, refer to the [Proxmox VE Cloud-Init Support documentation](https://pve.proxmox.com/wiki/Cloud-Init_Support).