Default SSH Usernames For Connecting To AWS 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:
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
, the provided user generally has passwordless
access to run commands as the
user. You can use
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: