Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 with root@... and the fedora images with ec2-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?

share|improve this question

closed as too localized by Tom O'Connor, voretaq7 Feb 10 '13 at 0:26

This question is unlikely to help any future visitors; it is only relevant to a small geographic area, a specific moment in time, or an extraordinarily narrow situation that is not generally applicable to the worldwide audience of the internet. For help making this question more broadly applicable, visit the help center.If this question can be reworded to fit the rules in the help center, please edit the question.

This is, unfortunately, a "look in the documentation" situation. – Skaperen Feb 9 '13 at 9:53
What do you mean exactly? The AMI's don't really come with any documentation? – Jeroen Feb 9 '13 at 21:45
@Jeroen We can't answer this for you (especially as you haven't seen fit to tell us which AMIs you're asking about - there are a LOT of them). Only the person who created the AMI can tell you what the default usernames are. You need to ask the person, organization, or other entity that created the AMI. – voretaq7 Feb 10 '13 at 0:26
Ok, that answers the question. IMHO, it would make sense to let the user specify this username, along with the keypair, when launching the instance. I am still not sure why the username is hardcoded by the ami creator, whereas the pubkey for this user can be specified by the user. Why else would they let me pick an AMI from the community repository? – Jeroen Feb 10 '13 at 3:50
up vote 1 down vote accepted

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.

share|improve this answer
Thank you this answers the question. It's a bit counter intuitive for me though: they do let you specify a keypair on launch, but don't tell you which username this keypair will be given. Not sure if and how this really improves security. – Jeroen Feb 10 '13 at 3:53

This is from Amazon Docs AWS DOCS

In User name, enter the user name to log in to your instance.

Note For an Amazon Linux instance, the default user name is ec2-user. For Ubuntu, the default user name is ubuntu. Some AMIs allow you to log in as root. So in this example, you may need to change the user name from ec2-user to the appropriate user name.

share|improve this answer
This basically just restates the question... – ceejayoz Feb 9 '13 at 23:17

Not the answer you're looking for? Browse other questions tagged or ask your own question.