I'm using Packer to boot a pre-installed Debian Buster image on QEMU to provision it for deployment, but whenever Packer boots the image it is unable to connect over SSH.
The Debian image is the default cd install fully updated and with
openssh-server
installed and PermitRootLogin
set to yes
. Packer will boot the image and try and connect over SSH but the SSH server doesn't start until I connect to the VNC.
Here is the QEMU command being run:
/usr/bin/qemu-system-x86_64 -name packer-qemu -machine type=pc,accel=tcg -netdev user,id=user.0,hostfwd=tcp::3841-:22 -device virtio-net,netdev=user.0 -drive file=image/packer-qemu,if=virtio,cache=writeback,discard=ignore,format=qcow2 -boot c -m 1024 -vnc 127.0.0.1:0
I have confirmed this issue with multiple machines and multiple versions of QEMU.
I can reproduce the issue without Packer, just running the QEMU commands myself.
Looking at systemd-analyze
, the ssh.service
just hangs until the VNC is connected.
If I put the ssh server into debug mode I get a **Missing privilege separation directory: /run/sshd** error. The directory exists if the VNC is connected and the SSH server is not in debug.
My hunch is that QEMU isn't creating a console port, or something along that line, but I'm not sure how to fix it.
Here is my Packer file:
{
"builders": [
{
"type": "qemu",
"iso_url": "file:/home/user/buster.img",
"iso_checksum_type": "none",
"disk_image": "true",
"vm_name": "base.raw",
"headless": "true",
"cpus": "1",
"memory": "1024",
"boot_wait": "2m",
"shutdown_command": "systemctl poweroff",
"ssh_timeout": "2m",
"ssh_username": "root",
"ssh_password": "password",
"output_directory": "image"
}
]
}
Asked by Cirrith
(11 rep)
Jan 22, 2020, 01:37 AM
Last activity: Jan 22, 2020, 07:36 AM
Last activity: Jan 22, 2020, 07:36 AM