Skip to content
Mementropy
Lab NotesHomelab notebookField note

SSH refused connections right after the VM's first boot

Cloud-init's package upgrade was restarting openssh.

By Ryan Hammang

I cloned the new workload VM from my Ubuntu cloud-init template and started it.

Eight seconds later the guest agent answered and reported the VM’s address. The next command, ssh, failed:

ssh: connect to host ... port 22: Connection refused

The guest agent talks over a virtual serial channel, not the network. So I could look inside without SSH:

Terminal window
qm guest exec 100 -- bash -c "systemctl status ssh.socket; tail -n 25 /var/log/cloud-init-output.log"

The cloud-init log showed openssh-server and a new kernel being set up.

Proxmox’s cloud-init drive turns on package upgrades on first boot by default (ciupgrade: 1). While dpkg was replacing openssh-server, the SSH socket was stopped for about 15 seconds. When the upgrade finished, SSH came back. I rebooted into the new kernel.

I’m glad I baked the guest agent into the template earlier today. The stock Ubuntu cloud image doesn’t include it, and without it I’d have been guessing.

Recipes written later from this work: