Cloud-Init - Wie SSH Hosts key bei Änderungen nicht neu generieren

Vengance

Well-Known Member
May 21, 2016
270
11
58
33
Hi,

Cloud-Init setzt bei jedem config change (hostname, SSH key etc.) einen neuen SSH hosts key, wodurch der SSH client dann per default eine Warnung wirft.

Wenn ich das richtig verstanden habe, scheint cloud-init ohne metadata service davon auszugehen, dass es sich um eine neue Instanz handelt und generiert demnach den Key neu.
Kann ich das verhalten irgendwie abstellen? Es ist etwas nervig, jedesmal den server aus den know_hosts zu entfernen.



Danke!
 
Welches Gastbetriebssystem verwendest du denn? VM config?
Code:
qm config <vmid>
 
Es werden die offiziellen Cloud Images genutzt.
In dem Beispiel das aktuelle Debian 11 Cloud Image

Code:
agent: 1
boot: c
bootdisk: scsi0
cores: 1
cpu: host
ide2: local-zfs:vm-9000-cloudinit,media=cdrom
memory: 1024
meta: creation-qemu=6.2.0,ctime=1659619942
name: debian11
nameserver: 1.1.1.1
net0: virtio=92:00:62:73:61:59,bridge=vmbr0,firewall=1
numa: 0
scsi0: local-zfs:base-9000-disk-0,discard=on,size=2G
scsihw: virtio-scsi-pci
serial0: socket
smbios1: uuid=ba417551-21b9-42c6-a86a-48be46d0d781
sockets: 1
template: 1
vga: serial0
vmgenid: 5270f696-8dd7-4a23-bf45-d0b7ad2fe59a
 
Yes das habe ich bereits alles durchgelesen.
Hat jemand noch eine andere Idee?
 
Niemand noch eine Idee?
Bei jedem erneuten run von Cloudinit nach der initialen config, werden die SSH host keys neu generiert.
Leider recht nervig
 
@Vengance hab jetzt nen workaround gebaut, der setzt allerdings voraus, dass du ciuser und cipassword gesetzt hast (kann man auch random via vault, externe variable, etc... setzen)

YAML:
  connection {
    type     = "ssh"
    user     = self.ciuser
    password = self.cipassword
    host     = self.name
  }
   provisioner "remote-exec" {
    inline = [
      "echo 'ssh_deletekeys: false' | sudo tee -a /etc/cloud/cloud.cfg.d/ssh.cfg"
    ]
  }
 
  • Like
Reactions: boris64

About

The Proxmox community has been around for many years and offers help and support for Proxmox VE, Proxmox Backup Server, and Proxmox Mail Gateway.
We think our community is one of the best thanks to people like you!

Get your subscription!

The Proxmox team works very hard to make sure you are running the best software and getting stable updates and security enhancements, as well as quick enterprise support. Tens of thousands of happy customers have a Proxmox subscription. Get yours easily in our online shop.

Buy now!