Cloud-Init does not allow me to login

Hello everyone,

I am currently changing my cloud-init config file since I would like to not do the user creation via snippets. (Since I would like to do this via the Cloud-Init tab of the VM as this allows me per VM control and not needing to have every VM the same since they all use the same snippet/cloud-init config file.)

So now I have removed the users section in the cloud-init config file and added my prefered username, password and SSH key to the cloud-init tab of the VM.
But after I boot the cloud image for the first time, it does apply the network, and apt configuration correctly, but when I try to login via the specified user, I get a invalid username or password error.

Also when I try to login via SSH with my SSH key, I still cannot login as te VM does not reconize my key. (My key is a ssh-ed25519)

So I have no clue if cloud-init did create my specified user or not but ether way, I am not able to login.

Does any know what I did wrong or how to fix this?

My Cloud-Init config:
packages:
- qemu-guest-agent
- git
- figlet
- nala
- fail2ban
runcmd:
- cp /etc/fail2ban/jail.conf /etc/fail2ban/jail.local
- sed -i 's/backend = %(sshd_backend)s/backend = systemd\nmode = extra\nmaxretry = 3\nfindtime = 1d\nbantime = 1d\nignoreip = 127.0.0.1\/8/g' /etc/fail2ban/jail.local
- sed -i '/^#/!s/\[sshd\]/\[sshd\]\nenabled = true/g' /etc/fail2ban/jail.local
- systemctl restart fail2ban
- nala fetch --auto -y
- nala update
- systemctl enable qemu-guest-agent
- systemctl start qemu-guest-agent
- git clone https://github.com/realcryptonight/debian-install-scripts.git
- cd debian-install-scripts/
- chmod 755 setup-standard.sh
- ./setup-standard.sh
- cd ../
- rm -rf debian-install-scripts/

My Cloud-Init tab:
Schermafbeelding 2024-03-28 115423.png
 
CLI commands:
qm create 9000 --name "Debian 12" --ostype l26
qm set 9000 --net0 virtio,bridge=vmbr0
qm set 9000 --serial0 socket --vga serial0
qm set 9000 --memory 16384 --cores 4 --cpu host
qm set 9000 --scsi0 local:0,import-from="./cache/debian-12-generic-amd64.qcow2",discard=on,ssd=1
qm set 9000 --boot order=scsi0 --scsihw virtio-scsi-single
qm set 9000 --onboot 1
qm set 9000 --agent enabled=1,fstrim_cloned_disks=1
qm set 9000 --ide2 local:cloudinit
qm set 9000 --cicustom "user=local:snippets/standard.yml"
qm set 9000 --nameserver "nameservers"
qm disk resize 9000 scsi0 50G
qm template 9000
 
But I would guess that there is no way via cloud-init to run commands on the first boot without the user part?
And thus not allowing me to do anything with the user part via the GUI.
I am not sure I am parsing this correctly. That said, there is always "root" user (speaking of Linux systems). Almost everything in Cloud-Init runs in root context, unless specifically forced under user, although I am not sure how one would do it, perhaps via "sudo".
All official Cloud images contain a default user already. If you are building your own image, nothing stops you from baking that into initial fresh image.
In short, I am not quiet sure what problem you are trying to solve.



Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 
I was just trying things out to see if it would be possible.
For me it not a big deal if all VMs use the same username and SSH key but it would have been really easy if I could change it in the template instead of in the cloud-init config file if I needed a different username/SSH key for just one time.
 
The built-in GUI managed cloud-init is intentionally limited to basic functionality. If you need more than that, you need to use custom one.
If you want your template to have custom configuration from start, you need to modify the template. You can use qcow editing tools to do so, before importing the template file.

Good luck


Blockbridge : Ultra low latency all-NVME shared storage for Proxmox - https://www.blockbridge.com/proxmox
 

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!