Open menu

Make a Debian 12 Template Template on Proxmox


Do you want to make a Debian 12 template?

Your in the right place, I have 2 files that will reset debian and allow you to template it.

#!/bin/sh

apt update && apt dist-upgrade; \
truncate -s0 /etc/machine-id; \
truncate -s0 /etc/resolv.conf; \
rm -f /var/lib/dbus/machine-id; \
rm -f /etc/ssh/ssh_host_*; \
systemctl enable regenerate_ssh_host_keys.service; \
cat /dev/null > ~/.bash_history && history -c; \
shutdown -h now
[Unit]
Description=Regenerate SSH host keys
Before=ssh.service
ConditionFileIsExecutable=/usr/bin/ssh-keygen

[Service]
Type=oneshot
ExecStartPre=-/bin/dd if=/dev/hwrng of=/dev/urandom count=1 bs=4096
ExecStartPre=-/bin/sh -c "/bin/rm -f -v /etc/ssh/ssh_host_*_key*"
ExecStart=/usr/bin/ssh-keygen -A -v
ExecStartPost=/bin/systemctl disable regenerate_ssh_host_keys

[Install]
WantedBy=multi-user.target

The first file is the main script, it will:

The systemd service will regenerate SSH host keys and disable the service

Published: 28 May 2025 by Matt Horwood