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

Unable to create new AMI with latest SSM Agent in AWS

Open hc-github-team-packer opened this issue 3 years ago • 2 comments

This issue was originally opened by @marcottedan in https://github.com/hashicorp/packer/issues/11700 and has been migrated to this repository. The original issue description is below.


Overview of the Issue

Packer not working anymore with AWS SSM Agent 3.1.1188.0 but still works with 3.1.1045.0. I get the following error:

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

Reproduction Steps

packer build .

Packer version

From packer version 1.8.0

Simplified Packer Template

source "amazon-ebs" "base" {
  source_ami       = "aws-windows-server-2019 AMI"
  region           = "us-east-1"
  instance_type    = "m5a.large"
  ami_name         = "packer_2019_base-{{isotime `2006-01-02`}}"

  # Tell Packer to use SSH over SSM
  communicator  = "ssh"
  ssh_interface = "session_manager"
  ssh_username  = "Administrator"
  ssh_timeout   = "10m"
}

Operating system and Environment details

Windows Server 2019 AMI Using MacBookPro to run Packer

Log Fragments and crash.log files

*********@*********s-MacBook-Pro ssh % export PACKER_LOG=1
*********@*********s-MacBook-Pro ssh % packer build base_ssh.pkr.hcl
2022/04/07 14:13:53 [INFO] Packer version: 1.8.0 [go1.17.8 darwin amd64]
2022/04/07 14:13:53 [TRACE] discovering plugins in /usr/local/bin
2022/04/07 14:13:53 [TRACE] discovering plugins in /Users/*********/.config/packer/plugins
2022/04/07 14:13:53 [TRACE] discovering plugins in .
2022/04/07 14:13:53 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/04/07 14:13:53 [INFO] PACKER_CONFIG env var set; attempting to open config file: /Users/*********/.packerconfig
2022/04/07 14:13:53 [WARN] Config file doesn't exist: /Users/*********/.packerconfig
2022/04/07 14:13:53 [INFO] Setting cache directory: /Users/*********/.cache/packer
2022/04/07 14:13:53 [TRACE] listing potential installations for "github.com/hashicorp/amazon" that match ">= 0.0.1". plugingetter.ListInstallationsOptions{FromFolders:[]string{"/usr/local/bin/packer", ".", "/Users/*********/.config/packer/plugins"}, BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"darwin", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc00020e100)}}}}
2022/04/07 14:13:54 [TRACE] Found the following "github.com/hashicorp/amazon" installations: [{/Users/*********/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 v1.0.4}]
2022/04/07 14:13:54 [INFO] found external [chroot ebs ebssurrogate ebsvolume instance] builders from amazon plugin
2022/04/07 14:13:54 [INFO] found external [import] post-processors from amazon plugin
2022/04/07 14:13:54 found external [ami parameterstore secretsmanager] datasource from amazon plugin
2022/04/07 14:13:54 [TRACE] Starting external plugin /Users/*********/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 start datasource ami
2022/04/07 14:13:54 Starting plugin: /Users/*********/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 []string{"/Users/*********/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64", "start", "datasource", "ami"}
2022/04/07 14:13:54 Waiting for RPC address for: /Users/*********/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 Plugin address: unix /var/folders/xn/4s48qqfs7zn0nt4lnnqkwh4c0000gp/T/packer-plugin3257918978
2022/04/07 14:13:54 Received unix RPC address for /Users/*********/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64: addr is /var/folders/xn/4s48qqfs7zn0nt4lnnqkwh4c0000gp/T/packer-plugin3257918978
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 Waiting for connection...
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 Serving a plugin connection...
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 [TRACE] starting datasource ami
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 Found region us-east-1
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 Using AMI Filters {
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin:   Filters: [{
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin:       Name: "name",
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin:       Values: ["****-Windows-2019-Sever*"]
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin:     },{
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin:       Name: "root-device-type",
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin:       Values: ["ebs"]
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin:     },{
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin:       Name: "virtualization-type",
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin:       Values: ["hvm"]
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin:     }],
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin:   Owners: ["************"]
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: }
2022/04/07 14:13:54 [TRACE] Starting external plugin /Users/*********/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 start builder ebs
2022/04/07 14:13:54 Starting plugin: /Users/*********/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 []string{"/Users/*********/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64", "start", "builder", "ebs"}
2022/04/07 14:13:54 Waiting for RPC address for: /Users/*********/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 Plugin address: unix /var/folders/xn/4s48qqfs7zn0nt4lnnqkwh4c0000gp/T/packer-plugin841757213
2022/04/07 14:13:54 Received unix RPC address for /Users/*********/.config/packer/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64: addr is /var/folders/xn/4s48qqfs7zn0nt4lnnqkwh4c0000gp/T/packer-plugin841757213
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 Waiting for connection...
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 Serving a plugin connection...
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 [TRACE] starting builder ebs
2022/04/07 14:13:54 [TRACE] Starting internal plugin packer-provisioner-powershell
2022/04/07 14:13:54 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-provisioner-powershell"}
2022/04/07 14:13:54 Waiting for RPC address for: /usr/local/bin/packer
2022/04/07 14:13:54 packer-provisioner-powershell plugin: [INFO] Packer version: 1.8.0 [go1.17.8 darwin amd64]
2022/04/07 14:13:54 packer-provisioner-powershell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/04/07 14:13:54 packer-provisioner-powershell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /Users/*********/.packerconfig
2022/04/07 14:13:54 packer-provisioner-powershell plugin: [WARN] Config file doesn't exist: /Users/*********/.packerconfig
2022/04/07 14:13:54 packer-provisioner-powershell plugin: [INFO] Setting cache directory: /Users/*********/.cache/packer
2022/04/07 14:13:54 packer-provisioner-powershell plugin: args: []string{"packer-provisioner-powershell"}
2022/04/07 14:13:54 packer-provisioner-powershell plugin: Plugin address: unix /var/folders/xn/4s48qqfs7zn0nt4lnnqkwh4c0000gp/T/packer-plugin175450077
2022/04/07 14:13:54 Received unix RPC address for /usr/local/bin/packer: addr is /var/folders/xn/4s48qqfs7zn0nt4lnnqkwh4c0000gp/T/packer-plugin175450077
2022/04/07 14:13:54 packer-provisioner-powershell plugin: Waiting for connection...
2022/04/07 14:13:54 packer-provisioner-powershell plugin: Serving a plugin connection...
2022/04/07 14:13:54 [TRACE] Starting internal plugin packer-provisioner-powershell
2022/04/07 14:13:54 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-provisioner-powershell"}
2022/04/07 14:13:54 Waiting for RPC address for: /usr/local/bin/packer
2022/04/07 14:13:54 packer-provisioner-powershell plugin: [INFO] Packer version: 1.8.0 [go1.17.8 darwin amd64]
2022/04/07 14:13:54 packer-provisioner-powershell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/04/07 14:13:54 packer-provisioner-powershell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /Users/*********/.packerconfig
2022/04/07 14:13:54 packer-provisioner-powershell plugin: [WARN] Config file doesn't exist: /Users/*********/.packerconfig
2022/04/07 14:13:54 packer-provisioner-powershell plugin: [INFO] Setting cache directory: /Users/*********/.cache/packer
2022/04/07 14:13:54 packer-provisioner-powershell plugin: args: []string{"packer-provisioner-powershell"}
2022/04/07 14:13:54 packer-provisioner-powershell plugin: Plugin address: unix /var/folders/xn/4s48qqfs7zn0nt4lnnqkwh4c0000gp/T/packer-plugin3235242343
2022/04/07 14:13:54 packer-provisioner-powershell plugin: Waiting for connection...
2022/04/07 14:13:54 Received unix RPC address for /usr/local/bin/packer: addr is /var/folders/xn/4s48qqfs7zn0nt4lnnqkwh4c0000gp/T/packer-plugin3235242343
2022/04/07 14:13:54 packer-provisioner-powershell plugin: Serving a plugin connection...
2022/04/07 14:13:54 Build debug mode: false
2022/04/07 14:13:54 Force build: false
2022/04/07 14:13:54 On error:
2022/04/07 14:13:54 Waiting on builds to complete...
amazon-ebs.base: output will be in this color.
2022/04/07 14:13:54 Starting build run: amazon-ebs.base
2022/04/07 14:13:54 Running builder:

2022/04/07 14:13:54 [INFO] (telemetry) Starting builder amazon-ebs.base
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 Found region us-east-1
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 [INFO] AWS Auth provider used: "SharedCredentialsProvider"
==> amazon-ebs.base: Force Deregister flag found, skipping prevalidating AMI Name
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:54 Using AMI Filters {
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin:   ImageIds: ["ami-06e2613a3545048c4"]
2022/04/07 14:13:54 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: }
    amazon-ebs.base: Found Image ID: ami-06e2613a3545048c4
2022/04/07 14:13:55 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:55 [INFO] Finding AZ and VpcId for the given subnet 'subnet-0dcac40a257a52452'
2022/04/07 14:13:55 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:55 [INFO] AvailabilityZone found: 'us-east-1a'
==> amazon-ebs.base: Creating temporary keypair: packer_624f29e2-673c-6dcf-6b0c-7cfba08d4804
==> amazon-ebs.base: Creating temporary security group for this instance: packer_624f29e3-11af-c34e-65c8-fa8c243015ec
2022/04/07 14:13:56 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:56 [DEBUG] Waiting for temporary security group: sg-0769100a4d21f2315
2022/04/07 14:13:56 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:56 [DEBUG] Found security group sg-0769100a4d21f2315
2022/04/07 14:13:56 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:56 Using specified instance profile: my-vm-ssm-enabled-iam-role
2022/04/07 14:13:56 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:13:56 [DEBUG] base64 encoding user data...
==> amazon-ebs.base: Launching a source AWS instance...
==> amazon-ebs.base: Adding tags to source instance
    amazon-ebs.base: Adding tag: "Name": "Packer Builder"
    amazon-ebs.base: Instance ID: i-0dd60da0d06beda16
==> amazon-ebs.base: Waiting for instance (i-0dd60da0d06beda16) to become ready...
2022/04/07 14:14:30 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:30 [INFO] Not using winrm communicator, skipping get password...
2022/04/07 14:14:30 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:30 Found available port: 8039 on IP: 0.0.0.0
2022/04/07 14:14:30 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:30 ssm: Starting PortForwarding session to instance i-0dd60da0d06beda16
==> amazon-ebs.base: Using SSH communicator to connect: localhost
2022/04/07 14:14:30 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:30 [INFO] Waiting for SSH, up to timeout: 10m0s
==> amazon-ebs.base: Waiting for SSH to become available...
2022/04/07 14:14:30 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:30 [DEBUG] TCP connection to SSH ip/port failed: dial tcp [::1]:8039: connect: connection refused
2022/04/07 14:14:30 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:30 Retryable error: TargetNotConnected: i-0dd60da0d06beda16 is not connected.
2022/04/07 14:14:30 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:30 Retryable error: TargetNotConnected: i-0dd60da0d06beda16 is not connected.
2022/04/07 14:14:31 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:31 Retryable error: TargetNotConnected: i-0dd60da0d06beda16 is not connected.
2022/04/07 14:14:32 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:32 Retryable error: TargetNotConnected: i-0dd60da0d06beda16 is not connected.
2022/04/07 14:14:34 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:34 Retryable error: TargetNotConnected: i-0dd60da0d06beda16 is not connected.
2022/04/07 14:14:35 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:35 [DEBUG] TCP connection to SSH ip/port failed: dial tcp [::1]:8039: connect: connection refused
2022/04/07 14:14:37 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:37 Retryable error: TargetNotConnected: i-0dd60da0d06beda16 is not connected.
2022/04/07 14:14:40 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:40 [DEBUG] TCP connection to SSH ip/port failed: dial tcp [::1]:8039: connect: connection refused
2022/04/07 14:14:44 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:14:44 Retryable error: TargetNotConnected: i-0dd60da0d06beda16 is not connected.

// ... retries 5~ times

    amazon-ebs.base: Starting portForwarding session "*******************************************"
    amazon-ebs.base: Starting session with SessionId: *******************************************
2022/04/07 14:22:20 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:22:20 [DEBUG] TCP connection to SSH ip/port failed: dial tcp [::1]:8039: connect: connection refused
    amazon-ebs.base: Port 8039 opened for sessionId *******************************************.
    amazon-ebs.base: Waiting for connections...
2022/04/07 14:22:25 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:22:25 [INFO] Attempting SSH connection to localhost:8039...
2022/04/07 14:22:25 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:22:25 [DEBUG] reconnecting to TCP connection for SSH
    amazon-ebs.base: Connection accepted for session [*******************************************]
2022/04/07 14:22:25 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:22:25 [DEBUG] handshaking with SSH
2022/04/07 14:22:25 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:22:25 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2022/04/07 14:22:25 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:22:25 [DEBUG] Detected authentication error. Increasing handshake attempts.
2022/04/07 14:22:32 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:22:32 [INFO] Attempting SSH connection to localhost:8039...
2022/04/07 14:22:32 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:22:32 [DEBUG] reconnecting to TCP connection for SSH

// ... retries 5~ times

2022/04/07 14:23:31 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:23:31 [DEBUG] handshaking with SSH
2022/04/07 14:23:31 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:23:31 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2022/04/07 14:23:31 packer-plugin-amazon_v1.0.4_x5.0_darwin_amd64 plugin: 2022/04/07 14:23:31 [DEBUG] Detected authentication error. Increasing handshake attempts.
==> amazon-ebs.base: 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
==> amazon-ebs.base: Terminating the source AWS instance...
==> amazon-ebs.base: Bad exit status: -1
==> amazon-ebs.base: Cleaning up any extra volumes...
==> amazon-ebs.base: No volumes to clean up, skipping
==> amazon-ebs.base: Deleting temporary security group...
==> amazon-ebs.base: Deleting temporary keypair...
2022/04/07 14:25:04 [INFO] (telemetry) ending amazon-ebs.base
==> Wait completed after 11 minutes 9 seconds
2022/04/07 14:25:04 machine readable: error-count []string{"1"}
==> Some builds didn't complete successfully and had errors:
2022/04/07 14:25:04 machine readable: amazon-ebs.base,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.
2022/04/07 14:25:04 [INFO] (telemetry) Finalizing.
Build 'amazon-ebs.base' errored after 11 minutes 9 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

==> Wait completed after 11 minutes 9 seconds

==> Some builds didn't complete successfully and had errors:
--> amazon-ebs.base: 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.

hc-github-team-packer avatar Apr 08 '22 16:04 hc-github-team-packer

I am getting the same results with a slightly different configuration targeting an Amazon Linux 2 AMI instead of a Windows AMI, and with a different ssh_username, as the issue describes. Packer version 1.8.3.

As a side note, my configuration below uses a non-default VPC. It works when I use the ssh_username = "ec2-user" but fails when I set it as shown below to ssm-user.

source "amazon-ebs" "my-ami" {
  # ... snipped some details like name, IAM role ...
  ami_virtualization_type = "hvm"
  secret_key               = "${var.aws_secret_key}"
  source_ami               = "${data.amazon-ami.amzn2-latest.id}"
  communicator             = "ssh"
  ssh_interface            = "session_manager"
  ssh_username             = "ssm-user"
  subnet_id                = var.my_subnet
  vpc_filter {
    filters = {
      isDefault  = "false"
      "tag:Name" = var.vpc_name
    }
  }
}

andrewtcymmer avatar Sep 14 '22 23:09 andrewtcymmer

I'm getting the same problem. Windows_Server-2019-English-Full-Base latest AMI, Packer running on Ubuntu (GitAgent Action agent).

pascalro-croesus avatar Aug 18 '23 20:08 pascalro-croesus