I am attempting to orchestrate several EC2 instances from my own set of scripts. The one issue I'm running into is that some of our boxes are ubuntu boxes which require that the user "ubuntu" be used to SSH into the box. The other boxes are all Amazon Linux nodes which require that you log in using the username "ec2-user" by default.

I have looked at the EC2 api's in pretty good detail and haven't been able to find a call that I can make to determine the node's default username.

Anyone have experience with this or have any ideas?


Well, from the API, you can obtain the AMI ID it was launched with, then by looking at the AMI metadata, you can determine which OS it is and therefore what username you should use.

  • I was really hoping I'd be able to make a call and get a definite username back. With this solution, I might as well just make an array of known usernames and try them all until one works. I just hate to do that because it's going to show up in the logs and raise a red flag. – Mike Keen Apr 29 '15 at 17:04
  • 2
    EC2 really knows nothing about what users are present on the instance itself. The best you can do in your case is to infer which username to use based on the AMI metadata. – EEAA Apr 29 '15 at 17:05
  • Yeah that's probably going to be the way to go :/ – Mike Keen Apr 29 '15 at 17:06
  • Another option for you going forward would be to add a "username" tag to your instances, and then you can query that. – EEAA Apr 29 '15 at 17:07
  • These are pre-existing customer instances that I don't control unfortunately. – Mike Keen Apr 29 '15 at 17:08

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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