Default ssh Usernames For Connecting To EC2 Instances

Each AMI publisher on EC2 decides what user (or users) should have ssh access enabled by default and what ssh credentials should allow you to gain access as that user.

For the second part, most AMIs allow you to ssh in to the system with the ssh keypair you specified at launch time. This is so common, users often assume that it is built in to EC2 even though it must be enabled by each AMI provider.

Unfortunately, there is no standard ssh username that is used to access EC2 instances across operating systems, distros, and AMI providers.

Here are some of the ssh usernames that I am aware of at this time:

OS/Distro Official AMI
ssh Username
Legacy / Community / Other AMI
ssh Usernames
Amazon Linux ec2-user
Ubuntu ubuntu root
Debian admin root
RHEL 6.4 and later ec2-user
RHEL 6.3 and earlier root
Fedora fedora ec2-user, root
Centos centos root
SUSE ec2-user root
BitNami bitnami
TurnKey root
NanoStack ubuntu
FreeBSD ec2-user
OmniOS root

Even though the above list will get you in to most official AMIs, there may still be situations where you aren’t quite sure how the AMI was built or what user should be used for ssh.

If you know you have the correct ssh key but don’t know the username, this code can be used to try a number of possibilities, showing which one(s) worked:


for user in ec2-user ubuntu centos fedora admin bitnami root 
  if timeout 5 ssh -i $keyfile $user@$host true 2>/dev/null; then
    echo "ssh -i $keyfile $user@$host"

Some AMIs are configured so that an ssh to root@ will output a message informing you the correct user to use and then close the connection. For example,

$ ssh root@<UBUNTUHOST>
Please login as the user "ubuntu" rather than the user "root".

When you ssh to a username other than root, the provided user generally has passwordless sudo access to run commands as the root user. You can use sudo, ssh, and rsync with EC2 hosts in this configuration.

If you know of other common ssh usernames from popular AMI publishers, please add notes in the comments with a link to the appropriate documentation.

Amazon has added a list of some default ssh usernames in their documentation. Depending on the month, it may be more or less up to date than this article:

[Update 2015-12-04: CentOS 7 now uses ssh to the centos user instead of root. Thanks to Cloudist for posting in the comments.]

[Update 2017-01-20: Fedora now uses ssh to the fedora user instead of ec2-user or root. Thanks to Ashok for posting in the comments.]

[Update 2018-03-16: Suse now uses ssh to the ec2-user user instead of root. Thanks to Aaron, @_Dad_Ops on Twitter.]

[Update 2018-03-16: Link to Amazon’s list.]