anthony@webserver:~$ apt search cloud-init
Sorting... Done
Full Text Search... Done
cloud-init/jammy,now 22.1-14-g2e17a0d6-0ubuntu1~22.04.5 all [installed,automatic]
initialization and customization tool for cloud instances
anthony@webserver:~$ cd /etc/ssh
anthony@webserver:/etc/ssh$ ls
moduli ssh_host_dsa_key ssh_host_ed25519_key.pub
ssh_config ssh_host_dsa_key.pub ssh_host_rsa_key
ssh_config.d ssh_host_ecdsa_key ssh_host_rsa_key.pub
sshd_config ssh_host_ecdsa_key.pub ssh_import_id
sshd_config.d ssh_host_ed25519_key
anthony@webserver:/etc/ssh$ sudo rm ssh_host_*
[sudo] password for anthony:
anthony@webserver:/etc/ssh$ ls
moduli ssh_config ssh_config.d sshd_config sshd_config.d ssh_import_id
the location of this file may vary or not be used at all depending on the distro, on ubuntu is /etc/machine-id, note that we empty the file not deleting the file itself
anthony@webserver:~$ cat /etc/machine-id
f16ace04b8544f01b97d6a5e9043df8a
anthony@webserver:~$ sudo truncate -s 0 /etc/machine-id
anthony@webserver:~$ cat /etc/machine-id
anthony@webserver:~$
anthony@webserver:~$ ls -l /var/lib/dbus/machine-id
lrwxrwxrwx 1 root root 15 Jun 1 01:16 /var/lib/dbus/machine-id -> /etc/machine-id
or
anthony@webserver:~$ sudo ln -s /etc/machine-id /var/lib/dbus/machine-id
anthony@webserver:~$ ls -l /var/lib/dbus/machine-id
lrwxrwxrwx 1 root root 15 Jun 1 01:16 /var/lib/dbus/machine-id -> /etc/machine-id
anthony@webserver:~$ sudo apt clean
[sudo] password for anthony:
anthony@webserver:~$ sudo apt autoremove
Reading package lists... Done
Building dependency tree... Done
Reading state information... Done
0 upgraded, 0 newly installed, 0 to remove and 0 not upgraded.
for instance: qemu-guest-agent
anthony@webserver:~$ sudo apt install qemu-guest-agent
this process with destroy the VM itself, beware
- edit CD/DVD drive and select 'do not use any media'
- add Cloud-init drice and select 'local-lvm'
- edit User to add a default username
- edit password for that User
- click 'regenerate image'
- right-click the template, click 'Clone'
- select the Target Node (pve), select Mode (Linked or Full clone( Full clone is better)), type a Name and VM id, Target Storage is lvm-thin in my case, and click 'clone'
- if you cant ssh into the new VMs:
check if the ssh service failed to run, in my case reinstalling openssh-server solved it
sudo apt reinstall openssh-server