Timeout waiting for SSH for Ubuntu 20.04 LTS Desktop image creation

Hello, I am creating ubuntu 20.04 LTS images using packer,

I stuck with ==> ubuntu- Waiting for SSH to become available…

So far I have tried with multiple attempts at the different time settings in the ssh_wait_timeout such as 30min, 45min, 1hrs, and 2hr but still, I am getting the same issue.

“ssh_wait_timeout”: “1h”,
“ssh_handshake_attempts”: “10”,
Packer version: 1.7.2
“type”: “virtualbox-iso”

==> virtualbox-iso: Waiting for SSH to become available…
==> virtualbox-iso: Timeout waiting for SSH.
==> virtualbox-iso: Timeout waiting for SSH.
==> virtualbox-iso: Step “StepConnect” failed
==> virtualbox-iso: [c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)?

May I know what is wrong with my preseed.cfg/ json file…? how to address the above error…?

Thanks in advance.

sshissue.txt (4.4 KB)

Dump question first: is the openssh-server package installed in the desktop version? To be sure I would trigger the installation during the preseed/ autoinstaller phase.

@Wolfsrudel thanks for your response. I have added d-i pkgsel/include string openssh-server build-essential in the preseed.cfg still I am getting the same ssh timeout and hang error. But still, I am debugging the issue.

Do you have any suggestions to use the publicly available templates and preseed.cfg file that’s work for the Ubuntu 20.04 LTS desktop image creation.

Ok, let’s go through this step by step: can the machine be pinged while Packer is waiting for ssh?

In the meantime I’m looking for suitable templates. This is rarely seen for desktop, although the deviations should actually be small.

Couple debugging tips:

  • set the env var PACKER_LOG=1 so you can get verbose logs.
  • set “headless:false” and actually connect to see what’s going on from the vm console. That’ll help you debug much faster than just guessing and waiting. Virtualbox uses rdp to connect.

Do you specify the user in the user-data?
Don’t forget to enable RootLogin and PasswordAuthentication unless you use SSH keys:

    - sed -i -e 's/^#\?PasswordAuthentication.*/PasswordAuthentication yes/g' /target/etc/ssh/sshd_config
    - sed -i -e 's/^#\?PermitRootLogin.*/PermitRootLogin yes/g' /target/etc/ssh/sshd_config