Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SSH Handshake Error When Trying to Build CentOS Stream 9 Image (using amazon-ebs plugin) #11958

Closed
erinf-wolf opened this issue Aug 23, 2022 · 5 comments

Comments

@erinf-wolf
Copy link

erinf-wolf commented Aug 23, 2022

Community Note

  • Please vote on this issue by adding a 👍 reaction to the original issue to help the community and maintainers prioritize this request
  • Please do not leave "+1" or other comments that do not add relevant new information or questions, they generate extra noise for issue followers and do not help prioritize the request
  • If you are interested in working on this issue or have submitted a pull request, please leave a comment

Overview of the Issue

Running into the same issue as in prev issue: #11656

It's caused by security settings in CentOS Stream 9 (and other modern distros) that disallow incoming rsa connections that utilize a key with SHA-1 signature. This was caused by an issue in the Go crypto package, although @nywilken mentioned the latest version of packer is now built using a version of Go that has the fix for this ... #8609 (comment)

However, using that version (1.8.1) and latest version (1.8.3), my build still fails. I'm using the latest version of amazon-ebs plugin 1.3.1 and made sure to manually uninstall and reinstall it as well. If this issue is specific to amazon-ebs I can open an issue on that repo.

Note I am using the correct ssh username ec2-user

Reproduction Steps

Try to run a build with a centos stream 9 image such as

    source_ami_filter {
      filters = {
        name = "CentOS Stream 9 x86_64 20220808"
      }
      most_recent = true
      owners      = ["${local.redhat_community_platform_engineering_owner_id}"]
    }

Packer version

From packer version

1.8.3

Simplified Packer Template

I can post if needed, I am avoiding so I don't have to sanitize it to remove personal info

It's very simple and works for all my other rpm based builds. Literally just launch the build and run a provisioner to update the packages with dnf. But never gets to that point anyways since can't connect

Operating system and Environment details

MacOS monterey 12.5.1
Using a very old version of Make to call the packer command but don't think that will change anything

Log Fragments and crash.log files

sanitized the log a bit to remove ip addresses and some other personal info

Build Log
2022/08/23 14:09:42 [INFO] Packer version: 1.8.1 [go1.17.8 darwin amd64]
2022/08/23 14:09:42 Old default config directory found: /Users/dfsdsfds/.packer.d
2022/08/23 14:09:42 [TRACE] discovering plugins in /usr/local/bin
2022/08/23 14:09:42 Old default config directory found: /Users/dfsdsfds/.packer.d
2022/08/23 14:09:42 [TRACE] discovering plugins in /Users/dfsdsfds/.packer.d/plugins
2022/08/23 14:09:42 [DEBUG] Discovered plugin: amazon = /Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.0_x5.0_darwin_amd64
2022/08/23 14:09:42 [DEBUG] Discovered plugin: amazon = /Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.6_x5.0_darwin_amd64
2022/08/23 14:09:42 [DEBUG] Discovered plugin: amazon = /Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.8_x5.0_darwin_amd64
2022/08/23 14:09:42 [DEBUG] Discovered plugin: amazon = /Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.1.0_x5.0_darwin_amd64
2022/08/23 14:09:42 [DEBUG] Discovered plugin: amazon = /Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64
2022/08/23 14:09:43 [INFO] found external [chroot ebs ebssurrogate ebsvolume instance] builders from amazon plugin
2022/08/23 14:09:43 [INFO] found external [import] post-processors from amazon plugin
2022/08/23 14:09:43 found external [ami parameterstore secretsmanager] datasource from amazon plugin
2022/08/23 14:09:43 [TRACE] discovering plugins in .
2022/08/23 14:09:43 [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/08/23 14:09:43 [INFO] PACKER_CONFIG env var set; attempting to open config file: /Users/dfsdsfds/.packerconfig
2022/08/23 14:09:43 [WARN] Config file doesn't exist: /Users/dfsdsfds/.packerconfig
2022/08/23 14:09:43 Old default config directory found: /Users/dfsdsfds/.packer.d
2022/08/23 14:09:43 [INFO] Setting cache directory: /Users/dfsdsfds/.cache/packer
2022/08/23 14:09:43 Old default config directory found: /Users/dfsdsfds/.packer.d
2022/08/23 14:09:43 [TRACE] listing potential installations for "github.com/hashicorp/amazon" that match "1.1.3". plugingetter.ListInstallationsOptions{FromFolders:[]string{"/usr/local/bin/packer", ".", "/Users/dfsdsfds/.packer.d/plugins"}, BinaryInstallationOptions:plugingetter.BinaryInstallationOptions{APIVersionMajor:"5", APIVersionMinor:"0", OS:"darwin", ARCH:"amd64", Ext:"", Checksummers:[]plugingetter.Checksummer{plugingetter.Checksummer{Type:"sha256", Hash:(*sha256.digest)(0xc00054c980)}}}}
2022/08/23 14:09:43 [TRACE] version "v1.0.0" of file "/Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.0_x5.0_darwin_amd64" does not match constraint "1.1.3"
2022/08/23 14:09:43 [TRACE] version "v1.0.6" of file "/Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.6_x5.0_darwin_amd64" does not match constraint "1.1.3"
2022/08/23 14:09:43 [TRACE] version "v1.0.8" of file "/Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.0.8_x5.0_darwin_amd64" does not match constraint "1.1.3"
2022/08/23 14:09:43 [TRACE] version "v1.1.0" of file "/Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.1.0_x5.0_darwin_amd64" does not match constraint "1.1.3"
2022/08/23 14:09:43 [TRACE] Found the following "github.com/hashicorp/amazon" installations: [{/Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 v1.1.3}]
2022/08/23 14:09:43 [INFO] found external [chroot ebs ebssurrogate ebsvolume instance] builders from amazon plugin
2022/08/23 14:09:43 [INFO] found external [import] post-processors from amazon plugin
2022/08/23 14:09:43 found external [ami parameterstore secretsmanager] datasource from amazon plugin
2022/08/23 14:09:43 [TRACE] validateValue: not active for is_test_build, so skipping
2022/08/23 14:09:43 [TRACE] validateValue: not active for ami_users, so skipping
2022/08/23 14:09:43 [TRACE] validateValue: not active for region, so skipping
2022/08/23 14:09:43 [TRACE] validateValue: not active for instance_type, so skipping
2022/08/23 14:09:43 [TRACE] validateValue: not active for vpc_id, so skipping
2022/08/23 14:09:43 [TRACE] validateValue: not active for subnet_id, so skipping
2022/08/23 14:09:43 [TRACE] Starting external plugin /Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 start builder ebs
2022/08/23 14:09:43 Starting plugin: /Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 []string{"/Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64", "start", "builder", "ebs"}
2022/08/23 14:09:43 Waiting for RPC address for: /Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64
2022/08/23 14:09:43 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:43 Plugin address: unix /var/folders/3w/crm557gx5zq1dhcbkvt5kkhm0000gq/T/packer-plugin1150823857
2022/08/23 14:09:43 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:43 Waiting for connection...
2022/08/23 14:09:43 Received unix RPC address for /Users/dfsdsfds/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64: addr is /var/folders/3w/crm557gx5zq1dhcbkvt5kkhm0000gq/T/packer-plugin1150823857
2022/08/23 14:09:43 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:43 Serving a plugin connection...
2022/08/23 14:09:43 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:43 [TRACE] starting builder ebs
2022/08/23 14:09:43 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:43 [INFO] (aws): No AWS timeout and polling overrides have been set. Packer will default to waiter-specific delays and timeouts. If you would like to customize the length of time between retries and max number of retries you may do so by setting the environment variables AWS_POLL_DELAY_SECONDS and AWS_MAX_ATTEMPTS or the configuration options aws_polling_delay_seconds and aws_polling_max_attempts to your desired values.
2022/08/23 14:09:43 [TRACE] Starting internal plugin packer-provisioner-shell
2022/08/23 14:09:43 Starting plugin: /usr/local/bin/packer []string{"/usr/local/bin/packer", "plugin", "packer-provisioner-shell"}
2022/08/23 14:09:43 Waiting for RPC address for: /usr/local/bin/packer
2022/08/23 14:09:43 packer-provisioner-shell plugin: [INFO] Packer version: 1.8.1 [go1.17.8 darwin amd64]
2022/08/23 14:09:43 packer-provisioner-shell plugin: Old default config directory found: /Users/dfsdsfds/.packer.d
2022/08/23 14:09:43 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var not set; checking the default config file path
2022/08/23 14:09:43 packer-provisioner-shell plugin: [INFO] PACKER_CONFIG env var set; attempting to open config file: /Users/dfsdsfds/.packerconfig
2022/08/23 14:09:43 packer-provisioner-shell plugin: [WARN] Config file doesn't exist: /Users/dfsdsfds/.packerconfig
2022/08/23 14:09:43 packer-provisioner-shell plugin: Old default config directory found: /Users/dfsdsfds/.packer.d
2022/08/23 14:09:43 packer-provisioner-shell plugin: [INFO] Setting cache directory: /Users/dfsdsfds/.cache/packer
2022/08/23 14:09:43 packer-provisioner-shell plugin: args: []string{"packer-provisioner-shell"}
2022/08/23 14:09:43 packer-provisioner-shell plugin: Old default config directory found: /Users/dfsdsfds/.packer.d
2022/08/23 14:09:43 packer-provisioner-shell plugin: Plugin address: unix /var/folders/3w/crm557gx5zq1dhcbkvt5kkhm0000gq/T/packer-plugin2765125056
2022/08/23 14:09:43 packer-provisioner-shell plugin: Waiting for connection...
2022/08/23 14:09:43 Received unix RPC address for /usr/local/bin/packer: addr is /var/folders/3w/crm557gx5zq1dhcbkvt5kkhm0000gq/T/packer-plugin2765125056
2022/08/23 14:09:43 packer-provisioner-shell plugin: Serving a plugin connection...
2022/08/23 14:09:43 ui: �[1;32mamazon-ebs.stagent-centos-stream-9-server: output will be in this color.�[0m
2022/08/23 14:09:43 ui: 
2022/08/23 14:09:43 Build debug mode: false
2022/08/23 14:09:43 Force build: false
2022/08/23 14:09:43 On error: 
2022/08/23 14:09:43 Waiting on builds to complete...
2022/08/23 14:09:43 Starting build run: amazon-ebs.stagent-centos-stream-9-server
2022/08/23 14:09:43 Running builder: 
2022/08/23 14:09:43 [INFO] (telemetry) Starting builder amazon-ebs.stagent-centos-stream-9-server
2022/08/23 14:09:43 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:43 [INFO] Attempting to use session-derived credentials
2022/08/23 14:09:45 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:45 [INFO] Successfully derived credentials from session
2022/08/23 14:09:45 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:45 [INFO] AWS Auth provider used: "AssumeRoleProvider"
2022/08/23 14:09:45 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:45 Found region x
2022/08/23 14:09:45 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:45 [INFO] AWS Auth provider used: "AssumeRoleProvider"
2022/08/23 14:09:46 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: Force Deregister flag found, skipping prevalidating AMI Name�[0m
2022/08/23 14:09:46 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:46 Using AMI Filters {
2022/08/23 14:09:46 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin:   Filters: [{
2022/08/23 14:09:46 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin:       Name: "name",
2022/08/23 14:09:46 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin:       Values: ["CentOS Stream 9 x86_64 20220808"]
2022/08/23 14:09:46 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin:     }],
2022/08/23 14:09:46 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin:   Owners: ["x"]
2022/08/23 14:09:46 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: }
2022/08/23 14:09:47 ui: �[0;32m    amazon-ebs.stagent-centos-stream-9-server: Found Image ID: ami-0f071d403de89e97e�[0m
2022/08/23 14:09:47 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:47 [INFO] Finding AZ and VpcId for the given subnet 'x
2022/08/23 14:09:47 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:47 [INFO] AvailabilityZone found: 'xa'
2022/08/23 14:09:47 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: Creating temporary keypair: x�[0m
2022/08/23 14:09:48 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: Creating temporary security group for this instance: x�[0m
2022/08/23 14:09:48 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:48 [DEBUG] Waiting for temporary security group: x
2022/08/23 14:09:49 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:09:49 [DEBUG] Found security group x
2022/08/23 14:09:49 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: Authorizing access to port 22 from [10.0.0.0/8] in the temporary security groups...�[0m
2022/08/23 14:09:50 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: Launching a source AWS instance...�[0m
2022/08/23 14:09:50 ui: �[0;32m    amazon-ebs.stagent-centos-stream-9-server: Adding tag: "Builder": "efarrag"�[0m
2022/08/23 14:09:50 ui: �[0;32m    amazon-ebs.stagent-centos-stream-9-server: Adding tag: "Image": "stagent"�[0m
2022/08/23 14:09:50 ui: �[0;32m    amazon-ebs.stagent-centos-stream-9-server: Adding tag: "Profile": "dev"�[0m
2022/08/23 14:09:50 ui: �[0;32m    amazon-ebs.stagent-centos-stream-9-server: Adding tag: "Role": "packer"�[0m
2022/08/23 14:09:51 ui: �[0;32m    amazon-ebs.stagent-centos-stream-9-server: Instance ID: i-092df15d5a096e11c�[0m
2022/08/23 14:09:51 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: Waiting for instance (i-092df15d5a096e11c) to become ready...�[0m
2022/08/23 14:10:08 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:08 [INFO] Not using winrm communicator, skipping get password...
2022/08/23 14:10:08 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: Using SSH communicator to connect: hostIpAddr�[0m
2022/08/23 14:10:08 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:08 [INFO] Waiting for SSH, up to timeout: 5m0s
2022/08/23 14:10:08 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: Waiting for SSH to become available...�[0m
2022/08/23 14:10:08 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:08 Using host value: hostIpAddr
2022/08/23 14:10:19 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:19 [DEBUG] TCP connection to SSH ip/port failed: dial tcp desetIpAddr: connect: connection refused
2022/08/23 14:10:24 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:24 Using host value: hostIpAddr
2022/08/23 14:10:24 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:24 [INFO] Attempting SSH connection to desetIpAddr...
2022/08/23 14:10:24 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:24 [DEBUG] reconnecting to TCP connection for SSH
2022/08/23 14:10:24 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:24 [DEBUG] handshaking with SSH
2022/08/23 14:10:26 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:26 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2022/08/23 14:10:26 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:26 [DEBUG] Detected authentication error. Increasing handshake attempts.
2022/08/23 14:10:33 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:33 Using host value: hostIpAddr
2022/08/23 14:10:33 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:33 [INFO] Attempting SSH connection to desetIpAddr...
2022/08/23 14:10:33 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:33 [DEBUG] reconnecting to TCP connection for SSH
2022/08/23 14:10:33 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:33 [DEBUG] handshaking with SSH
2022/08/23 14:10:35 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:35 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2022/08/23 14:10:35 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:35 [DEBUG] Detected authentication error. Increasing handshake attempts.
2022/08/23 14:10:42 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:42 Using host value: hostIpAddr
2022/08/23 14:10:42 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:42 [INFO] Attempting SSH connection to desetIpAddr...
2022/08/23 14:10:42 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:42 [DEBUG] reconnecting to TCP connection for SSH
2022/08/23 14:10:42 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:42 [DEBUG] handshaking with SSH
2022/08/23 14:10:43 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:43 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2022/08/23 14:10:43 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:43 [DEBUG] Detected authentication error. Increasing handshake attempts.
2022/08/23 14:10:50 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:50 Using host value: hostIpAddr
2022/08/23 14:10:50 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:50 [INFO] Attempting SSH connection to desetIpAddr...
2022/08/23 14:10:50 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:50 [DEBUG] reconnecting to TCP connection for SSH
2022/08/23 14:10:51 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:51 [DEBUG] handshaking with SSH
2022/08/23 14:10:52 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:52 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2022/08/23 14:10:52 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:52 [DEBUG] Detected authentication error. Increasing handshake attempts.
2022/08/23 14:10:59 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:59 Using host value: hostIpAddr
2022/08/23 14:10:59 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:59 [INFO] Attempting SSH connection to desetIpAddr...
2022/08/23 14:10:59 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:59 [DEBUG] reconnecting to TCP connection for SSH
2022/08/23 14:10:59 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:10:59 [DEBUG] handshaking with SSH
2022/08/23 14:11:01 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:01 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2022/08/23 14:11:01 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:01 [DEBUG] Detected authentication error. Increasing handshake attempts.
2022/08/23 14:11:08 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:08 Using host value: hostIpAddr
2022/08/23 14:11:08 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:08 [INFO] Attempting SSH connection to desetIpAddr...
2022/08/23 14:11:08 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:08 [DEBUG] reconnecting to TCP connection for SSH
2022/08/23 14:11:08 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:08 [DEBUG] handshaking with SSH
2022/08/23 14:11:10 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:10 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2022/08/23 14:11:10 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:10 [DEBUG] Detected authentication error. Increasing handshake attempts.
2022/08/23 14:11:17 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:17 Using host value: hostIpAddr
2022/08/23 14:11:17 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:17 [INFO] Attempting SSH connection to desetIpAddr...
2022/08/23 14:11:17 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:17 [DEBUG] reconnecting to TCP connection for SSH
2022/08/23 14:11:17 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:17 [DEBUG] handshaking with SSH
2022/08/23 14:11:19 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:19 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2022/08/23 14:11:19 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:19 [DEBUG] Detected authentication error. Increasing handshake attempts.
2022/08/23 14:11:26 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:26 Using host value: hostIpAddr
2022/08/23 14:11:26 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:26 [INFO] Attempting SSH connection to desetIpAddr...
2022/08/23 14:11:26 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:26 [DEBUG] reconnecting to TCP connection for SSH
2022/08/23 14:11:26 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:26 [DEBUG] handshaking with SSH
2022/08/23 14:11:27 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:27 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2022/08/23 14:11:27 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:27 [DEBUG] Detected authentication error. Increasing handshake attempts.
2022/08/23 14:11:34 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:34 Using host value: hostIpAddr
2022/08/23 14:11:35 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:35 [INFO] Attempting SSH connection to desetIpAddr...
2022/08/23 14:11:35 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:35 [DEBUG] reconnecting to TCP connection for SSH
2022/08/23 14:11:35 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:35 [DEBUG] handshaking with SSH
2022/08/23 14:11:36 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:36 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2022/08/23 14:11:36 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:36 [DEBUG] Detected authentication error. Increasing handshake attempts.
2022/08/23 14:11:43 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:43 Using host value: hostIpAddr
2022/08/23 14:11:43 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:43 [INFO] Attempting SSH connection to desetIpAddr...
2022/08/23 14:11:43 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:43 [DEBUG] reconnecting to TCP connection for SSH
2022/08/23 14:11:44 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:44 [DEBUG] handshaking with SSH
2022/08/23 14:11:45 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:45 [DEBUG] SSH handshake err: ssh: handshake failed: ssh: unable to authenticate, attempted methods [none publickey], no supported methods remain
2022/08/23 14:11:45 packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64 plugin: 2022/08/23 14:11:45 [DEBUG] Detected authentication error. Increasing handshake attempts.
2022/08/23 14:11:45 ui error: �[1;31m==> amazon-ebs.stagent-centos-stream-9-server: 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�[0m
2022/08/23 14:11:45 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: Terminating the source AWS instance...�[0m
2022/08/23 14:12:32 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: Cleaning up any extra volumes...�[0m
2022/08/23 14:12:33 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: No volumes to clean up, skipping�[0m
2022/08/23 14:12:33 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: Deleting temporary security group...�[0m
2022/08/23 14:12:34 ui: �[1;32m==> amazon-ebs.stagent-centos-stream-9-server: Deleting temporary keypair...�[0m
2022/08/23 14:12:34 [INFO] (telemetry) ending amazon-ebs.stagent-centos-stream-9-server
2022/08/23 14:12:34 ui error: �[1;31mBuild 'amazon-ebs.stagent-centos-stream-9-server' errored after 2 minutes 51 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�[0m
2022/08/23 14:12:34 ui: 
==> Wait completed after 2 minutes 51 seconds
2022/08/23 14:12:34 machine readable: error-count []string{"1"}
2022/08/23 14:12:34 ui error: 
==> Some builds didn't complete successfully and had errors:
2022/08/23 14:12:34 machine readable: amazon-ebs.stagent-centos-stream-9-server,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"}
2022/08/23 14:12:34 ui error: --> amazon-ebs.stagent-centos-stream-9-server: 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
2022/08/23 14:12:34 ui: 
==> Builds finished but no artifacts were created.
2022/08/23 14:12:34 [INFO] (telemetry) Finalizing.
2022/08/23 14:12:35 waiting for all plugin processes to complete...
2022/08/23 14:12:35 /Users/jkhhjk/.packer.d/plugins/github.com/hashicorp/amazon/packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64: plugin process exited
2022/08/23 14:12:35 /usr/local/bin/packer: plugin process exited
@erinf-wolf erinf-wolf added the bug label Aug 23, 2022
@github-actions github-actions bot removed the bug label Aug 23, 2022
@nywilken
Copy link
Contributor

Hi @erinf-wolf thanks for reaching out. I updated your description a bit to fix the build log formatting. Quickly looking at the logs I see you're referencing version 1.8.3 for your environment. But it looks like you are actually running Packer 1.8.1. It might not be an issue but its helpful to provide the logs for both version if testing old and new.

That said, for Centos distros I believe the username is "centos" and not "ecs-user", which is used for Amazon Linux boxes.

Have you tried using a different username?

Using the AMI id from your logs I am able to provision using the centos username.

AMI ID in provided logs

2022/08/23 14:09:47 ui: �[0;32m    amazon-ebs.stagent-centos-stream-9-server: Found Image ID: ami-0f071d403de89e97e�[0m

Results of my local test running Packer 1.8.3 with packer-plugin-amazon_v1.1.3_x5.0_darwin_amd64

~>  packer build amazon-ebs_centos9_shell_local.pkr.hcl
amazon-ebs.basic-example: output will be in this color.

==> amazon-ebs.basic-example: Prevalidating any provided VPC information
==> amazon-ebs.basic-example: Prevalidating AMI Name: packer_AWS 1661352204
    amazon-ebs.basic-example: Found Image ID: ami-0f071d403de89e97e
==> amazon-ebs.basic-example: Creating temporary keypair: packer_6306390c-cb49-26e7-6220-4104ff48cf6c
==> amazon-ebs.basic-example: Creating temporary security group for this instance: packer_63063923-253b-c8be-d487-4f1954bbb1ec
==> amazon-ebs.basic-example: Authorizing access to port 22 from [0.0.0.0/0] in the temporary security groups...
==> amazon-ebs.basic-example: Launching a source AWS instance...
    amazon-ebs.basic-example: Instance ID: i-0c5d41188dccd3b1a
==> amazon-ebs.basic-example: Waiting for instance (i-0c5d41188dccd3b1a) to become ready...
==> amazon-ebs.basic-example: Using SSH communicator to connect: 35.90.175.103
==> amazon-ebs.basic-example: Waiting for SSH to become available...
==> amazon-ebs.basic-example: Connected to SSH!
==> amazon-ebs.basic-example: Provisioning with shell script: /var/folders/vz/rv7bk6v15211jxg8q801f7kw0000gq/T/packer-shell4247599969
    amazon-ebs.basic-example: Linux ip-172-31-0-233.us-west-2.compute.internal 5.14.0-142.el9.x86_64 #1 SMP PREEMPT_DYNAMIC Thu Aug 4 18:15:17 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
    amazon-ebs.basic-example: ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQCm/C763uI3Dk6Hg7KR/VIS1tiW9IFTTbk/xL9xeYCc/BStp1lJW5p+RnqnqY0aQVhK1lQIg1jMBo3s2ZHIHHi1G+jqfP7vpjmAtTnlH6wdbIIAJUg9FsI+fIf0usVy9kQmtfcEmxiHVqFk+okidORL630Kmt6fc9eWHDr23Enl94QxRTO+N6AOl54msrFssnzZ0aZxNnZAMO5iz4KuyBRwF7QU+FMd3gigrSiFjyQSw6LPyuJRsR8LKk//D1r8xRnh2W4TEkM8IDAw46zOlKAZtfMMy1DOxN53GE3dwuAw+DwmTmya1sc6ANlpj/wvgiP7konVilp9Wou/MH/ol/mT packer_6306390c-cb49-26e7-6220-4104ff48cf6c

Below is another build setting temporary_key_pair_type = "ed25519"

~>  packer build amazon-ebs_centos9_shell_local.pkr.hcl
amazon-ebs.basic-example: output will be in this color.

==> amazon-ebs.basic-example: Prevalidating any provided VPC information
==> amazon-ebs.basic-example: Prevalidating AMI Name: packer_AWS 1661352939
    amazon-ebs.basic-example: Found Image ID: ami-0f071d403de89e97e
==> amazon-ebs.basic-example: Creating temporary keypair: packer_63063beb-2a5d-b0c1-7676-e9594b8b6b23
==> amazon-ebs.basic-example: Creating temporary security group for this instance: packer_63063c02-3699-68e3-56ae-bc452c59b36b
==> amazon-ebs.basic-example: Authorizing access to port 22 from [0.0.0.0/0] in the temporary security groups...
==> amazon-ebs.basic-example: Launching a source AWS instance...
    amazon-ebs.basic-example: Instance ID: i-0981424f08e91f167
==> amazon-ebs.basic-example: Waiting for instance (i-0981424f08e91f167) to become ready...
==> amazon-ebs.basic-example: Using SSH communicator to connect: 54.212.156.197
==> amazon-ebs.basic-example: Waiting for SSH to become available...
==> amazon-ebs.basic-example: Connected to SSH!
==> amazon-ebs.basic-example: Provisioning with shell script: /var/folders/vz/rv7bk6v15211jxg8q801f7kw0000gq/T/packer-shell1920651412
    amazon-ebs.basic-example: CentOS Stream release 9
    amazon-ebs.basic-example: Contents of key filessh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIK44+tAX2RhREYVc67UsZRvvwCwnbgC+vM3T1Mz70+Ak packer_63063beb-2a5d-b0c1-7676-e9594b8b6b23
==> amazon-ebs.basic-example: Stopping the source instance...
    amazon-ebs.basic-example: Stopping instance
==> amazon-ebs.basic-example: Waiting for the instance to stop...
==> amazon-ebs.basic-example: Creating AMI packer_AWS 1661352939 from instance i-0981424f08e91f167
    amazon-ebs.basic-example: AMI: ami-04c051a56b6602a22
==> amazon-ebs.basic-example: Waiting for AMI to become ready...
==> amazon-ebs.basic-example: Skipping Enable AMI deprecation...
==> amazon-ebs.basic-example: Modifying attributes on AMI (ami-04c051a56b6602a22)...
    amazon-ebs.basic-example: Modifying: users
==> amazon-ebs.basic-example: Modifying attributes on snapshot (snap-06623b3551449e0ee)...
==> amazon-ebs.basic-example: Terminating the source AWS instance...
==> amazon-ebs.basic-example: Cleaning up any extra volumes...
==> amazon-ebs.basic-example: No volumes to clean up, skipping
==> amazon-ebs.basic-example: Deleting temporary security group...
==> amazon-ebs.basic-example: Deleting temporary keypair...
Build 'amazon-ebs.basic-example' finished after 6 minutes 3 seconds.

Below is my full HCL template for reference

packer {
  required_plugins {
    amazon = {
      source  = "github.com/hashicorp/amazon"
      version = ">=v1.1.2"
    }
  }
}
source "amazon-ebs" "basic-example" {
  region                  = "us-west-2"
  spot_price              = "0"
  source_ami              = "ami-0f071d403de89e97e"
  instance_type           = "t2.small"
  ssh_username            = "centos"
  ssh_agent_auth          = false
  temporary_key_pair_type = "ed25519"
  ami_name                = "packer_AWS {{timestamp}}"
}

build {
  sources = [
    "source.amazon-ebs.basic-example"
  ]

  provisioner "shell" {
    inline = ["cat /etc/redhat-release", "echo -n Contents of key file", "cat ~/.ssh/authorized_keys"]
  }


}

@erinf-wolf
Copy link
Author

erinf-wolf commented Aug 25, 2022

Ah excellent, thanks so much! It must be a username issue since indeed bug should be fixed since 1.8.1 ... Yep I tried both 1.8.3. and 1.8.1. and had same result

My team will retry build + close ticket once confirming works! Note this might take a week or a bit longer as started work on another task, another developer from my team will be the one to check it + close this issue.

@nywilken
Copy link
Contributor

Sounds good @erinf-wolf. Thanks for the update.

@nywilken nywilken removed their assignment Aug 31, 2022
@github-actions
Copy link

Hi,

This issue has not received any update in the last 3 weeks, and will automatically be closed in 7 days if it does not receive any activity by then.

If you find the community forum to be more helpful or if you've found the answer to your question elsewhere please feel free to post a response and close the issue.

@github-actions
Copy link

I'm going to lock this issue because it has been closed for 30 days ⏳. This helps our maintainers find and focus on the active issues.
If you have found a problem that seems similar to this, please open a new issue and complete the issue template so we can capture all the details necessary to investigate further.

@github-actions github-actions bot locked as resolved and limited conversation to collaborators Oct 29, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants