hashicorp / packer-plugin-googlecompute

Packer plugin for Google Compute Builder
https://www.packer.io/docs/builders/googlecompute
Mozilla Public License 2.0
23 stars 51 forks source link

SSH connection fails with ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain while using custom ssh-key #156

Open rilla0308 opened 1 year ago

rilla0308 commented 1 year ago

When filing a bug, please include the following headings if possible. Any example text in this template can be deleted.

Overview of the Issue

I am using google compute plugin version 1.1.0 and packer version 1.7.2 I am hitting the error Build 'googlecompute' errored after 1 minute 58 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

Reproduction Steps

I am using google compute plugin version 1.1.0 and packer version 1.7.2

Steps to reproduce this issue

Plugin and Packer version

I am using google compute plugin version 1.1.0 and packer version 1.7.2

Simplified Packer Buildfile

{ "builders": [ { "type": "googlecompute", "project_id": "core-autobuilds-production", "account_file": "/home/build/packer-workspace/adc.json", "source_image": "rhel-20230119-03-secure", "disk_size": "310", "subnetwork": "prod-pod-gcp-1", "omit_external_ip": "true", "ssh_username": "cloud-user", "ssh_private_key_file": "/home/build/.ssh/gcp-rhel9", "ssh_keypair_name": "gcp-rhel9", "temporary_key_pair_type": "ed25519", "use_internal_ip": "true", "state_timeout": "60m", "disable_default_service_account": "true", "metadata": { "ssh-keys": "cloud-user: **** cloud-user"}, "zone": "us-central1-a" } ], "provisioners": [ { "type": "shell", "inline": ["echo Welcome to RHEL9"] } ] }

Operating system and Environment details

Centos7

Log Fragments and crash.log files

Include appropriate log fragments. If the log is longer than a few dozen lines, https://gist.github.com/rilla0308/53bacba7e3983dc7b47758117cfc069b

Set the env var PACKER_LOG=1 for maximum log detail.

rilla0308 commented 1 year ago

I have been stuck with this issue for two days - crazy part is i am able to ssh to the vm with same ssh key from the same host to the vm which Packer is creating

rilla0308 commented 1 year ago

The issue is with packer version 1.7.2 when i upgraded to packer version 1.8.4 ssh connection was successful

VakarisZ commented 2 weeks ago

For me it was root username on debian image that caused this problem