What is the default username for Amazon AMI images of Ubuntu Server?

On EC2 all the Ubuntu AMI's should be connected to like so:

$ ssh -i your-ssh-key.pem [email protected]

So you connect as the 'ubuntu' user using the ssh key you injected into the instance at launch (not a password). Once authenticated, you can issue password-less root commands with sudo.

(note: your ssh key might be .priv, or .pem, or no extension, this is just an example)

Here are also some handy resources about connecting to EC2 instances:

Launching an instance and choosing or creating a new SSH keypair: http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide/index.html?LaunchInstance.html

Connecting with your ssh keypair: http://docs.amazonwebservices.com/AWSEC2/latest/GettingStartedGuide/index.html?ConnectToInstanceLinux.html

What they don't mention there is that you connect to Ubuntu instances with the 'ubuntu' account and not root.


Extra tips:

  1. I prefer to type ssh ubuntu@host instead of ssh -i your-ssh-key.pem ubuntu@host.

    I wrote an article that describes how to do this:

    Uploading Personal ssh Keys to Amazon EC2
    http://alestic.com/2010/10/ec2-ssh-keys

  2. If you're always logging in to EC2 hosts using ubuntu you can even make that the default for when you use the standard EC2 instance public host name. This lets you just type ssh hostname. To do this, edit $HOME/.ssh/config and add a section like:

    Host *.amazonaws.com
      User ubuntu
    

As a further option, if you don't want to use personal ssh keys (although probably the best solution) but want to simplify the command line, add your key to ~/.ssh/ and add the following to ~/.ssh/config:

Host ec2-xxx-xxx-xxx-xxx.xxxx.compute.amazonaws.com
 User ubuntu
 IdentityFile ~/.ssh/yourkey.pem

Then you can simply use ssh ec2-xxx-xxx-xxx-xxx.xxxx.compute.amazonaws.com

If you have your EC2 registered to a domain then you can also use the following:

Host yourdomain.com
 User ubuntu
 IdentityFile ~/.ssh/yourkey.pem

Then you can use ssh yourdomain.com

Finally, to simplify it without a domain, use an alias as follows:

Host myalias
 HostName ec2-xxx-xxx-xxx-xxx.xxxx.compute.amazonaws.com
 User ubuntu
 IdentityFile ~/.ssh/yourkey.pem

Then you can use ssh myalias