Hi All,
I have an issue when SSH’ing into an Alpine linux EC2 instance. Unless I put my “ssh_private_key_file” information in the build file I am unable to SSH into it after the build is complete and I create the EC2 instance from the created AMI.
Related issue: ssh_private_key_file is of limited use without key_pair_name parameter · Issue #1635 · hashicorp/packer · GitHub
Is this intended for most linux builds that you have to pre-bake your private key into ~/.ssh/authorized_keys from your AWS keypair otherwise it won’t work? Because I can create an Ubuntu 20.04 image and spin it up on EC2 and ssh while only having to select my keypair on AWS. (as seen below)
{
"variables": {
"aws_profile": "test-env",
"ami_name": "alpine-ami-3.13.5-x86_64-r0-test5",
"region": "us-east-1"
},
"builders": [
{
"name": "Alpine AMI Builder",
"type": "amazon-ebs",
"profile": "{{ user `aws_profile`}}",
"iam_instance_profile": "ec2-instance-profile",
"source_ami": "ami-068216a0f0800db09",
"ami_name": "{{user `ami_name`}}",
"region": "us-east-1",
"instance_type": "t3a.medium",
"ssh_username": "alpine",
"ssh_keypair_name": "ssh-keypair-name",
"ssh_private_key_file": "~/ssh-keypair-name.pem",
"tags": {
"Name": "{{user `ami_name`}}"
}
}
]
}