Cloning two VMs from the same system disk and changing their names and addresses does not give them independent identities. Monitoring tools may merge the two machines, initialization scripts may incorrectly decide they have “already run,” and SSH clients may see the same host fingerprint. These problems are embedded in the disk contents; the names shown in the VM list tell you nothing about them.
Using Debian 12 VMs on Proxmox VE 8/9 as an example, this guide follows a workflow of preparation, sealing the template, creating two clones, and checking them again after a reboot. All changes are made to test VMs, not the physical host. Save a copy of the original template before modifying identity data.
Distinguish the three types of identity
/etc/machine-id is the system identifier used by systemd and some applications. SSH host keys establish the server’s identity; they are not the authorized_keys that allow accounts to log in. The cloud-init instance identifier determines which initialization modules should run for the first time on a given instance.
These three mechanisms are not interchangeable. Changing a virtual network adapter’s address does not remove the host’s private keys from the system disk, and clearing machine-id does not automatically clear the cloud-init cache. The acceptance criteria are straightforward: different clones must have independent identities, and each clone must retain its identity across reboots.
Do not clean a template directly on a machine that is already in production. Changing its identity may affect monitoring associations, license bindings, and SSH trust records. Template cleanup is a pre-deployment operation.
Application-specific node IDs, backup client identifiers, and registration tokens are also outside the scope of cloud-init’s general-purpose modules. Install the software in the template, but do not include production registration state.
Prepare the first-boot process
Run these steps inside a VM dedicated to building the template, using an account with administrative privileges. The examples use Bash. First, make sure cloud-init and the SSH server are installed:
sudo apt-get update
sudo apt-get install cloud-init openssh-server
cloud-init --version
cloud-init status --long
sudo systemctl is-enabled cloud-init-local.service cloud-init.service
Check whether /etc/cloud/cloud-init.disabled exists, and make sure cloud-init has not been disabled through kernel boot parameters. If cloud-init has not been used on this VM before, a successful installation is not enough to seal the template: complete a test boot first.
Add a Cloud-Init drive in the PVE configuration, then configure a test login public key and separate network settings. The drive must be attached to the clones, not just left on the template-building VM. On networks without DHCP, configure addresses explicitly rather than carrying over network assumptions from another environment.
Write the first-boot host key policy:
sudo tee /etc/cloud/cloud.cfg.d/99-template-ssh.cfg >/dev/null <<'EOF'
ssh_deletekeys: true
ssh_genkeytypes:
- ed25519
- rsa
EOF
sudo cloud-init schema --system
cloud-init clean --help
Confirm that the installed version supports --machine-id. Also check that cloud_init_modules in the base configuration includes ssh and that no other configuration overrides the key policy. These steps do not set a login username or connection port; use the connection settings explicitly defined for your test environment.
Seal the template immediately after cleanup
Let the template-building VM finish its current initialization, verify that you can log in with the test public key, and record the software versions and configuration. Before cleanup, remove application registration tokens, temporary credentials, and test data, while preserving the empty directories and permissions required by the applications.
The following commands clear the initialization cache and delete host keys. Run them only inside the template-building VM that is ready to be sealed:
sudo cloud-init clean --logs --machine-id
sudo rm -f /etc/ssh/ssh_host_*_key /etc/ssh/ssh_host_*_key.pub
sudo poweroff
--machine-id resets the identifier to a state suitable for the next first boot. Do not run systemd-machine-id-setup after cleanup: it could generate an identifier that all subsequent clones inherit.
Once the VM is powered off, convert it to a template in PVE. Do not boot the source disk again for a “final check,” because booting regenerates identity data. If changes are necessary, create a working copy from the template, make the changes, and repeat the cleanup and sealing process.
Deleting host keys does not mean Debian’s SSH service will handle all of their regeneration on its own. This workflow relies on cloud-init’s SSH module, so you must verify the drive, the data source, and the module’s execution results.
Compare the two clones
Create two test clones from the same template, attach their respective Cloud-Init data, and assign different names and network addresses. This check is required for both full and linked clones: the disk-copying method does not replace initialization inside the guest.
Check each clone’s metadata on the PVE host. In the following example, 201 is a test VM ID; replace it with the actual ID:
qm cloudinit dump 201 meta
The two clones must have different instance-id values. If you use custom metadata files, do not assign the same fixed instance identifier to every VM. Correct the metadata before starting new clones rather than repeatedly clearing caches to hide the problem.
Inside each guest, run:
sudo cloud-init status --wait
sudo cloud-init status --long
cat /etc/machine-id
cloud-init query v1.instance_id
sudo ssh-keygen -lf /etc/ssh/ssh_host_ed25519_key.pub
sudo sshd -t
Save each machine’s results separately in controlled records. The machine-id must be nonempty and in the expected format. Its value must differ between the two clones, as must the instance identifier. When comparing SSH fingerprints, compare the fingerprint field, not the filename or trailing comment.
If initialization reports errors, inspect /var/log/cloud-init.log and /var/log/cloud-init-output.log to check data source reads and SSH module execution. Do not publicly share complete logs containing public key configuration, network information, or initialization parameters.
Reboot and check for failure cases
Once the first-boot checks pass, reboot each test VM normally and collect the same set of results again. Each machine’s machine-id, instance identifier, and SSH fingerprint must remain unchanged. Proving that the two machines are different is not enough: identities that keep changing also break identity associations.
If the keys change on every reboot, first look for startup cleanup scripts, configuration tasks that run repeatedly, or instance metadata that keeps changing. Do not bypass warnings by disabling SSH host verification.
Verify SSH client records against fingerprints obtained through an independent, trusted channel. Fingerprints collected by scanning the network can be used for comparison, but cannot establish authenticity on their own. When reusing a test address, confirm the new machine’s identity before updating local trust records.
Keep four sets of evidence: the template configuration, the initial results from both clones, their respective post-reboot results, and the application registration state checks. Allow the template into routine use only after confirming that the clones do not share private keys or production tokens. Repeat this two-clone acceptance procedure after every template update rather than relying on the previous version’s results.
Frequently asked questions
Does changing a clone's name and IP remove duplicate identity?
No. A new name and IP do not reset the machine-id, cached cloud-init instance state or SSH host private keys stored on disk. Initialize and verify each separately.
Should SSH host keys change after every reboot?
No. Separate clones should have different host keys, but a given clone should retain its keys across normal reboots. Repeated changes require checking initialization and instance IDs.
EPYC 7543P Dedicated Server
From $459.9/month