Is there a way to discover or specify the username I need to use to ssh in to an ec2 instance? I know how to select my key pair, but depending on the ami, you need to use a different username.
For example, the official ubuntu images require you to ssh in with
ubuntu@...
, the debian images withroot@...
and the fedora images withec2-user@...
. However, sometimes I just want to search an ami from the ‘community AMI’s’, but then I don’t know which username my keypair was associated with.So how is one supposed to know this? Is there a way to specify this when launching the instance? Am I overlooking something?
Answer
Remember Amazon AMIs can be customized as well as created from scratch by anyone. So in theory, anyone can change the ssh user to any random user. As you mentioned the most common users are ubuntu, ec2-user and root, but there are some users who bundle their own AMIs and change the usernames to a different user for security reasons, to make it unpredictable. So either you have to rely on the documentation of the AMIs to see what user to use, or to try the conventional user names.
Attribution
Source : Link , Question Author : Jeroen Ooms , Answer Author : Daniel t.