How to Create a VM Template In Proxmox
In this video we will go over how to create a VM template in Proxmox so you do not need to repeat this step every single time you want to create a new service within your Proxmox environment.
Create a VM
The first thing you need to do is create a VM on one of your Proxmox nodes, in our case we will be using Ubuntu 25.x Server. As a general outline we will keep the template as 4 cores, 4 gigabytes of ram, and 50 gigabytes of storage. Remember you can change your specs later.
VM Configuration
In our case, we are going to configure the important items that MUST change, but other than that, leave the VM a nice blank slate.
Install Cloud Init
Cloud-init is the industry-standard open-source tool used to initialize, configure, and customize cloud instances (virtual machines) during their very first boot. It enables automation by setting up SSH keys, user accounts, networking, and installing packages, turning generic OS images into customized servers automatically.
Install it with:
sudo apt update && sudo apt upgrade -y
sudo apt install cloud-init -y
Check the version with:
cloud-init --version
To ensure it runs during the boot process perform the following commands:
sudo systemctl enable cloud-init-local.service
sudo systemctl enable cloud-config.service
sudo systemctl enable cloud-final.service
Remove SSH Keys
Removing SSH host keys from a VM before turning it into a template is a critical step for security and uniqueness. If you don't remove them, every VM you create from that template will share the exact same identity, which causes several technical and security issues.
When something like a host key is absent, on the start up of future virtual machines, they will be automatically created. Before that we need to use SSH service not SSH sockets. SSH service is always running, where sockets will only run an SSH client if it sees a connection attempt. The issue with SSH sockets is cloud-init cannot make a session to add keys automatically because it will fail. SSH socket is looking for keys to already be there.
sudo systemctl stop ssh.socket
sudo systemctl disable ssh.socket
sudo systemctl enable ssh.service
We need to do is change into the SSH directory:
cd /etc/ssh
Then we need to delete all files for SSH with the wild card command:
sudo rm ssh_host_*
Edit Machine Host Id File
A host ID for an Ubuntu server is a unique identifier used to lock software licenses to a specific machine, or a numerical value derived from your server's IP address and used by the operating system for identification.
You can see your host ID by performing the following:
cat /etc/machine-id
We cannot actually delete this file because it is a critical file for the operating system to function but we can empty the content of the file with:
sudo truncate -s 0 /etc/machine-id
You can then check the file to ensure it is empty with the below command again:
cat /etc/machine-id
There is another file that references this file and we need to ensure that connection is symbolically linked. We can see the link below (you will know it’s linked because it will point to our previous file location (→ ./etc/machine-id)) or with the (L) showing as linked at the beginning of the file permissions:
ls -l /var/lib/dbus/machine-id
In the Case It Is Not Symbolically Linked
If it is not linked, we need it to be linked. We can link it with this command:
sudo ln -s /etc/machine-id /var/lib/dbus/machine-id
Install QEMU Agent
Proxmox QEMU Guest Agent is a small, built-in background daemon that runs inside a virtual machine. It facilitates direct, secure communication between the Proxmox hypervisor and the VM’s operating system. It allows Proxmox to directly read and display the internal IP address of your Ubuntu server within the Proxmox Web GUI. It enables the "Shutdown" command in the Proxmox web interface to perform a graceful, OS-level shutdown. Without it, Proxmox is forced to use an emergency power-off (like pulling the plug) or ACPI signals.
It instructs Ubuntu to flush its memory cache and freeze its file system right before Proxmox takes a snapshot or backup. This ensures your databases and running services remain uncorrupted. The agent automatically syncs the internal clock of your Ubuntu server with the Proxmox host, preventing severe time drift
To install this agent, perform the following:
cd ~
sudo apt install qemu-guest-agent -y
- Navigate to the VM in Proxmox web GUI.
- Select the Options tab
- On the Qemu Guess Agent select it then enable it.
Clean the VM Image
The next thing we want to do is just clean up any bloat of our template with the following command:
sudo apt clean
As well as any orphaned packages:
sudo apt autoremove -y
We then need to clean the cloudinit files:
sudo cloud-init clean
Things You May Want to Do
- Have certain apps pre-downloaded on your image
- Have certain users already created
- Security and compliance like certain universal firewall rules
- Universal networking settings like a VLAN
- Configuration agents, maybe some type of end point device management software.
- Centralized endpoint monitoring software.
Power down the VM
Now we have our template, we want to power it down so we can save the template in Proxmox, perform the following command:
sudo poweroff
Creating the Proxmox Template
This is a one way process, this means when it becomes a template you can never undo this. You cannot edit this template going forward.
Before doing that:
If you are new to this process, you can actually clone this VM, then use that clone to create a template, edit the original VM in case your template had a mistake.
- Right-click on the VM
- Select Convert to template
- Confirm = yes
- Now in our Node tree, we can see a new Icon that looks like a piece of paper/monitor. That is the symbol Proxmox uses for a template.
- Select your template, from its settings tree select hardware
- Under hardware tab select the CD/DVD drive because that has our install ISO image still attached to the template.
- Select edit
- Select Do not use any media and press ok
- Next under hardware select add
- From the dropdown select CloudInit Drive
- Bus/Device = SCSI
- Storage: select your drive location where you want the VM to be created
- Select cloud-init from the template tree settings.
- Under this tab you can change the following default settings:
- User
- Password
- DNS Domain
- DNS Servers
- SSH Public Key
- Under this tab you can change the following default settings:
- Then select regenerate template at the top if you changed any of those Cloud-Init Settings.
How to Use Your VM Template
To use your new template, simply right-click on it, and select clone. You will then be presented with a template creation box where you will assign:
- VM name
- mode: (set to full Clone)
- Resource pool for your new VM.
- Target Storage: (set this to where you want the VM to run and be saved from).
- Under your new VM, before you start it perform the following:
- We noticed some VMs may not get an IP address to fix that do the following:
- Select the Cloud-Init Tab
- Select IP Config (net0)
- Edit it
- Enable DHCP (if not already selected)
- Start the VM
- Login to the VM
Change the Hostname
The one issue you may notice is that the VM hostname is the exact same across all VMs you create using the clone, we can change that on each new one we make when using the template.
sudo nano /etc/hostname
The next file we need to edit is, the name should be found on line two after a local IP of 127.0.1.1:
sudo nano /etc/hosts
Then we need to reboot our machine with:
sudo reboot