AWS – Get AMI default username from CLI

amazon-web-servicesaws-cli

I'd like to get the default username for an AMI on AWS. For example, I need to obtain the username shown in the box in this image, via API or CLI.

Any thoughts?enter image description here

Best Answer

The AWS infrastructure doesn't know the default username for an AMI. It's commonly ec2-user, or ubuntu, or whatever the AMI author decided it should be. Even the message on the console explains that this value is essentially just a guess.

Additionally, depending on the source of the AMI, it can be withdrawn -- deleted -- and any instances built from it will still function, but it's attributes can't be fetched, because it no longer exists.

Beyond that, once you have created an instance from an AMI, you have full control, and if you change that default username -- or the default SSH key to the instance, for that matter -- the AWS platform has no idea that you've changed it.