packer-plugin-googlecompute icon indicating copy to clipboard operation
packer-plugin-googlecompute copied to clipboard

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

Open rilla0308 opened this issue 2 years ago • 4 comments

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 avatar Apr 19 '23 12:04 rilla0308

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 avatar Apr 19 '23 12:04 rilla0308

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

rilla0308 avatar Apr 19 '23 14:04 rilla0308

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

VakarisZ avatar Jun 21 '24 18:06 VakarisZ

@VakarisZ Could you please share the solution? I've tried setting ssh_username to root as well, still getting the same

ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain

sshcherbakov avatar Feb 25 '25 16:02 sshcherbakov