I have an existing AWS Ubuntu EC2 instance (instance_1
) with remote ssh access via a public IP address, using my own private/public keys. I create an AMI from this instance using the console, and then launch a new EC2 instance (instance_2
) using this AMI. remote ssh to instance_2
(via its own public IP address) then works exactly as for instance_1
.
I then use boto3 to create an AMI instead of the console and then launch another EC2 instance (instance_3
). ssh authentication fails (Permission denied) on instance_3
.
Any idea why the behaviour is different when the AMI is created with boto3 instead of the console? The credentials used with boto3 allow full administrator access using policy arn:aws:iam::aws:policy/AdministratorAccess
.
The code to create the AMI:
ec2_client = boto3.client('ec2', region_name=region)
response = ec2_client.create_image(InstanceId=instance_id, Name=ami_name)
new_image_id = response['ImageId']