Googlecompute: Timeout waiting for SSH

I am trying to create the image on GCP and finding the SSH timeout error while building the image with Packer.

googlecompute: output will be in this color.

==> googlecompute: Checking image does not exist…

==> googlecompute: Creating temporary rsa SSH key for instance…

==> googlecompute: Using image: rhel-7-jenkins-master-1-0-0-67-g3b1d409

==> googlecompute: Creating instance…

googlecompute: Loading zone: us-central1-c

googlecompute: Loading machine type: n1-standard-1

googlecompute: Requesting instance creation…

googlecompute: Waiting for creation operation to complete…

googlecompute: Instance has been created!

==> googlecompute: Waiting for the instance to become running…

googlecompute: IP: 10.128.12.132

==> googlecompute: Using ssh communicator to connect: 10.128.12.132

==> googlecompute: Waiting for SSH to become available…

==> googlecompute: Timeout waiting for SSH.

==> googlecompute: Deleting instance…

googlecompute: Instance has been deleted!

==> googlecompute: Deleting disk…

googlecompute: Disk has been deleted!

Build ‘googlecompute’ errored after 6 minutes 9 seconds: Timeout waiting for SSH.

==> Wait completed after 6 minutes 9 seconds

==> Some builds didn’t complete successfully and had errors:

–> googlecompute: Timeout waiting for SSH.

==> Builds finished but no artifacts were created.

Hello there, do you have a buildfile for this one ?

Hello azr,

No, I don’t have buildfile for this.

What Azr means is, we need to see your packer template and preseed files, not just the logs, if you want help troubleshooting this.

I am running into this. I have tried the same thing with a few different Debian and Ubuntu images. The builder part of my config is:

{
“builders”: [
{
“type”: “googlecompute”,
“account_file”: “project-info.json”,
“project_id”: “private…”,
“source_image”: “ubuntu-minimal-2010-groovy-v20210113”,
“disk_size”: “30”,
“machine_type”: “f1-micro”,
“ssh_username”: “packer”,
“zone”: “us-central1-a”,
“image_description”: “packer image for generic web server”,
“preemptible”: true
}
],

Any pointers appreciated. I set this up a long time ago, forgot everything about Packer, and now I don’t want to get caught in a jam.

Thanks.

Interesting finding on this: if I run Packer with -debug, and take my time between the key steps (I assume the ones between creating the instance and connecting via ssh), it works. If I just let packer build run, it fails every time.

Mac OSX Big Sur (Silicon M1).

Reporting back…

My problem was fixed by adding the following to the builder json:

  "wait_to_add_ssh_keys": "20s",

It gave things enough time to catch up.

1 Like

Thank you tomdotorg!

It works for me as well :blush:

2 Likes