Hi everyone,
I’m facing an issue when using Packer with the image rocky-linux-9-optimized-gcp. The SSH connection fails, whereas the same setup works fine with rocky-linux-8-optimized-gcp.
However, if I change the default file permissions of gce_googlecompute.pem from 755 to 600 (chmod 600 gce_googlecompute.pem
), the SSH connection works fine from the command line in parallel if i test it, but not the same with packer.
Is this issue related to file permissions? If so, why does this problem not occur with the Rocky Linux 8 version?
Any help would be greatly appreciated!
Please find the error message below and let me know if there’s anything I need to fix.
2025/03/13 09:05:34 packer-builder-googlecompute plugin: [INFO] Waiting for SSH, up to timeout: 5m0s
2025-03-13T09:05:34Z: ==> googlecompute: Waiting for SSH to become available...
2025/03/13 09:05:49 packer-builder-googlecompute plugin: [DEBUG] TCP connection to SSH ip/port failed: dial tcp 35.186.191.95:22: i/o timeout
2025/03/13 09:05:54 packer-builder-googlecompute plugin: [DEBUG] TCP connection to SSH ip/port failed: dial tcp 35.186.191.95:22: connect: connection refused
2025/03/13 09:05:59 packer-builder-googlecompute plugin: [INFO] Attempting SSH connection to 35.186.191.95:22...
2025/03/13 09:05:59 packer-builder-googlecompute plugin: [DEBUG] reconnecting to TCP connection for SSH
2025/03/13 09:05:59 packer-builder-googlecompute plugin: [DEBUG] handshaking with SSH
2025/03/13 09:05:59 packer-builder-googlecompute plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2025/03/13 09:05:59 packer-builder-googlecompute plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2025/03/13 09:06:06 packer-builder-googlecompute plugin: [INFO] Attempting SSH connection to 35.186.191.95:22...
2025/03/13 09:06:06 packer-builder-googlecompute plugin: [DEBUG] reconnecting to TCP connection for SSH
2025/03/13 09:06:06 packer-builder-googlecompute plugin: [DEBUG] handshaking with SSH
2025/03/13 09:06:07 packer-builder-googlecompute plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [publickey none], no supported methods remain
2025/03/13 09:06:07 packer-builder-googlecompute plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2025/03/13 09:06:14 packer-builder-googlecompute plugin: [INFO] Attempting SSH connection to 35.186.191.95:22...
2025/03/13 09:06:14 packer-builder-googlecompute plugin: [DEBUG] reconnecting to TCP connection for SSH
2025/03/13 09:06:14 packer-builder-googlecompute plugin: [DEBUG] handshaking with SSH
2025/03/13 09:06:14 packer-builder-googlecompute plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2025/03/13 09:06:14 packer-builder-googlecompute plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2025/03/13 09:06:21 packer-builder-googlecompute plugin: [INFO] Attempting SSH connection to 35.186.191.95:22...
2025/03/13 09:06:21 packer-builder-googlecompute plugin: [DEBUG] reconnecting to TCP connection for SSH
2025/03/13 09:06:21 packer-builder-googlecompute plugin: [DEBUG] handshaking with SSH
2025/03/13 09:06:21 packer-builder-googlecompute plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2025/03/13 09:06:21 packer-builder-googlecompute plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2025/03/13 09:06:28 packer-builder-googlecompute plugin: [INFO] Attempting SSH connection to 35.186.191.95:22...
2025/03/13 09:06:28 packer-builder-googlecompute plugin: [DEBUG] reconnecting to TCP connection for SSH
2025/03/13 09:06:28 packer-builder-googlecompute plugin: [DEBUG] handshaking with SSH
2025/03/13 09:06:28 packer-builder-googlecompute plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2025/03/13 09:06:28 packer-builder-googlecompute plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2025/03/13 09:06:35 packer-builder-googlecompute plugin: [INFO] Attempting SSH connection to 35.186.191.95:22...
2025/03/13 09:06:35 packer-builder-googlecompute plugin: [DEBUG] reconnecting to TCP connection for SSH
2025/03/13 09:06:35 packer-builder-googlecompute plugin: [DEBUG] handshaking with SSH
2025/03/13 09:06:35 packer-builder-googlecompute plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2025/03/13 09:06:35 packer-builder-googlecompute plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2025/03/13 09:06:42 packer-builder-googlecompute plugin: [INFO] Attempting SSH connection to 35.186.191.95:22...
2025/03/13 09:06:42 packer-builder-googlecompute plugin: [DEBUG] reconnecting to TCP connection for SSH
2025/03/13 09:06:42 packer-builder-googlecompute plugin: [DEBUG] handshaking with SSH
2025/03/13 09:06:42 packer-builder-googlecompute plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2025/03/13 09:06:42 packer-builder-googlecompute plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2025/03/13 09:06:49 packer-builder-googlecompute plugin: [INFO] Attempting SSH connection to 35.186.191.95:22...
2025/03/13 09:06:49 packer-builder-googlecompute plugin: [DEBUG] reconnecting to TCP connection for SSH
2025/03/13 09:06:49 packer-builder-googlecompute plugin: [DEBUG] handshaking with SSH
2025/03/13 09:06:49 packer-builder-googlecompute plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2025/03/13 09:06:49 packer-builder-googlecompute plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2025/03/13 09:06:56 packer-builder-googlecompute plugin: [INFO] Attempting SSH connection to 35.186.191.95:22...
2025/03/13 09:06:56 packer-builder-googlecompute plugin: [DEBUG] reconnecting to TCP connection for SSH
2025/03/13 09:06:56 packer-builder-googlecompute plugin: [DEBUG] handshaking with SSH
2025/03/13 09:06:56 packer-builder-googlecompute plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2025/03/13 09:06:56 packer-builder-googlecompute plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2025/03/13 09:07:03 packer-builder-googlecompute plugin: [INFO] Attempting SSH connection to 35.186.191.95:22...
2025/03/13 09:07:03 packer-builder-googlecompute plugin: [DEBUG] reconnecting to TCP connection for SSH
2025/03/13 09:07:03 packer-builder-googlecompute plugin: [DEBUG] handshaking with SSH
2025/03/13 09:07:03 packer-builder-googlecompute plugin: [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2025/03/13 09:07:03 packer-builder-googlecompute plugin: [DEBUG] Detected authentication error. Increasing handshake attempts.
2025-03-13T09:07:03Z: ==> googlecompute: Error waiting for SSH: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2025-03-13T09:07:03Z: ==> googlecompute: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2025-03-13T09:07:03Z: ==> googlecompute: Step "StepConnect" failed
==> googlecompute: [c] Clean up and exit, [a] abort without cleanup, or [r] retry step (build may fail even if retry succeeds)? c
==> googlecompute: Pausing before cleanup of step 'StepStartTunnel'. Press enter to continue.
2025/03/13 09:07:14 packer-builder-googlecompute plugin: Skipping cleanup of IAP tunnel; "iap" is false.
==> googlecompute: Pausing before cleanup of step 'StepInstanceInfo'. Press enter to continue.
==> googlecompute: Pausing before cleanup of step 'StepCreateWindowsPassword'. Press enter to continue.
==> googlecompute: Pausing before cleanup of step 'StepCreateInstance'. Press enter to continue.
2025-03-13T09:07:17Z: ==> googlecompute: Deleting instance...
2025/03/13 09:07:17 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2025/03/13 09:07:19 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2025/03/13 09:07:21 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2025/03/13 09:07:24 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2025/03/13 09:07:26 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2025/03/13 09:07:28 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2025/03/13 09:07:30 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2025/03/13 09:07:32 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2025/03/13 09:07:34 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2025-03-13T09:07:36Z: googlecompute: Instance has been deleted!
2025-03-13T09:07:36Z: ==> googlecompute: Deleting disk...
2025/03/13 09:07:36 packer-builder-googlecompute plugin: Retryable error: retrying for state DONE, got RUNNING
2025-03-13T09:07:38Z: googlecompute: Disk has been deleted!
==> googlecompute: Pausing before cleanup of step 'StepImportOSLoginSSHKey'. Press enter to continue.
==> googlecompute: Pausing before cleanup of step 'StepCreateSSHKey'. Press enter to continue.
==> googlecompute: Pausing before cleanup of step 'StepCheckExistingImage'. Press enter to continue.
2025/03/13 09:07:42 [INFO] (telemetry) ending googlecompute
2025-03-13T09:07:42Z: Build 'googlecompute' errored after 2 minutes 22 seconds: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2025/03/13 09:07:42 Waiting on builds to complete...
==> Wait completed after 2 minutes 22 seconds
2025/03/13 09:07:42 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2025/03/13 09:07:42 machine readable: googlecompute,error []string{"Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain"}
==> Builds finished but no artifacts were created.
2025/03/13 09:07:42 Cancelling builder after context cancellation context canceled
2025/03/13 09:07:42 [INFO] (telemetry) Finalizing.
==> Wait completed after 2 minutes 22 seconds
==> Some builds didn't complete successfully and had errors:
--> googlecompute: Packer experienced an authentication error when trying to connect via SSH. This can happen if your username/password are wrong. You may want to double-check your credentials as part of your debugging process. original error: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
Thanks!