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
1 Like

Having the same issue. I’m using autoinstall cloud init config. After the first reboot packer does nothing. Port is forwarded to ssh, it’s possible to login using ssh, but it’s just waiting for a timeout. It happens when only i need it to login, when provisioner “ansible” {} is set. In a different configuration it works fine(without provisioners). It just logins and shutdowns the machine.

@ajaymas as far as I know, Ubuntu 20.04 doesn’t support debian-installer anymore, if I understand correctly. I’ve heard that only the legacy versions do. I think the point now is to use cloud-init directly.

@admssa how can people guess what’s happening if you don’t provide really anything related to your setup? You’re not even mentioning the second minor version etc.