Packer unable to SSH into Amazon Linux 2022

I’ve started experimenting with making a custom AMI with Amazon Linux 2022. I based this on a successful Amazon Linux 2 AMI project I have previously worked on. However during the initial setup phase I’m seeing an SSH error that Communicator cannot connect to the instance due to a Handshake error. Is this a known bug in packer at the moment? This SAME code works fine with Amazon Linux 2. Any guidance would be appreciated.

2 Likes

Hi @johnowens looking at the documentation for Amazon Linux 2022 it appears to based off of Fedora 35 which by default requires key pair types of ED25519. As of the current release of Packer and the Amazon Packer Plugin the only supported type for the Amazon builder is RSA.

However, we just merged in a new change to support ED25519 key types which should resolve this issue. To verify that this is indeed the issue I tested against the following template and confirmed that using a dev build of the latest plugin code fixes the issue.

I’ll follow up with the team on making an Amazon plugin release.

source "amazon-ebs" "basic-example" {
  region =  "us-west-2"
  source_ami = "ami-044065b5480679567"
  instance_type =  "t2.small"
  ssh_username =  "ec2-user"
  ssh_agent_auth = false
  temporary_key_pair_type = "ed25519"
  ami_name =  "packer_AWS {{timestamp}}"
}

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

  provisioner "shell"{
    inline = ["echo Hello from Amazon Linux 2022"]
  }

}

Excellent! I look forward to the release announcement!