How do I find the OS of a running EC2 instance?
Your best bet is to look up the ami
which will be in the "Description" tab of the instance. However, if the ami
is private or derived from another ami
then you won't be able to.
You can use this if you prefer the cli:
aws ec2 describe-instances --instance-ids your_id
The "Platform" tag is only helpful to identify if the OS is windows(or linux if not set).
Unfortunately, there isn't a 100% accurate way to identify the OS.
AWS can easily tell you if the OS is linux or Windows but telling you what exact distribution you are running won't be possible without a backdoor to your machine. AWS does not implement(at least they haven't publicly admitted of doing so) backdoors to the EC2 instances.
And even if they did - what defines a distribution? A few simple changes to system files or headers can turn "Ubuntu" into something else, while in fact it'll still effectively be Ubuntu.
As a matter of fact, if you look at the public AMIs you can see that they do say what distribution they are based on, but as soon as you generate a new AMI based on the public one - the distribution switches to Custom Linux.
There's one other optiong - nmap
. However, this is a topic of its own, it's not 100% accurate(again) and special conditions must be met. More here.
You can check through console by following procedure.
Select instance => Action => Instance setting => Get instance screenshot .
this will show the OS of your instance.
From Terminal inside EC2 instance: $ cat /etc/os-release
If you have a System Manager agent installed on your instances you can use DescribeInstanceInformation API to find that information:
$ aws ssm describe-instance-information --query 'InstanceInformationList[*].[InstanceId,PlatformType,PlatformName]' --output text --filters Key=InstanceIds,Values=i-016073859e4b31111
i-016073859e4b31111 Linux Amazon Linux AMI