[pve-devel] [PATCH qemu-server] cloud-init: don't regenerate ssh hosts key on config change when vm is running

Alexandre Derumier aderumier at odiso.com
Wed Jan 13 10:01:32 CET 2021


Currently, we always regenerate sshkeys on any config change.

It should be done only before the first vm start, but currently can't known that.

So, this patch only do it when vm is running.

Signed-off-by: Alexandre Derumier <aderumier at odiso.com>
---
 PVE/QemuServer/Cloudinit.pm | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/PVE/QemuServer/Cloudinit.pm b/PVE/QemuServer/Cloudinit.pm
index 52a4203..dd643c1 100644
--- a/PVE/QemuServer/Cloudinit.pm
+++ b/PVE/QemuServer/Cloudinit.pm
@@ -135,6 +135,8 @@ sub cloudinit_userdata {
 	    $content .= "  - $k\n";
 	}
     }
+    $content .= "ssh_deletekeys: false\n" if PVE::QemuServer::check_running($vmid);
+
     $content .= "chpasswd:\n";
     $content .= "  expire: False\n";
 
-- 
2.20.1




More information about the pve-devel mailing list