# Delete the host keys
sudo rm /etc/ssh/ssh_host_*
# Get current machine-id
cat /etc/machine-id > /tmp/machine-id.ORIG
# Delete current machine-id
sudo truncate -s 0 /etc/machine-id
Create a new VM from the NixOS template: Right click the template, then choose “Clone”.
Generate ssh host keys:
# Re-generate the host keys
sudo ssh-keygen -A
# Restart ssh daemon to use the new keys
sudo systemctl restart sshd
# check machine-id
cat /etc/machine-id
# Get current machine-id (will be different from the one on the template, that is stored at /tmp)
diff /etc/machine-id /tmp/machine-id.ORIG
# Generate new machine-id
sudo systemd-machine-id-setup
# Get current machine-id (will be different from the one on the template, that is stored at /tmp)
diff /etc/machine-id /tmp/machine-id.ORIG