When creating a new EC2 instance and create an Amazon Machine Image (AMI), a default user is automatically created for you. This user is typically the `ec2-user` on Amazon Linux, `ubuntu` on Ubuntu AMIs, and other similar names depending on the operating system. The AMI contains the configuration and software from your EC2 instance, and when you launch a new instance using the AMI, it comes with this user pre-configured, allowing you to log in.
There are many setups as default when creating and instance as part of security configuration, making it more secure that you can SSH into the instance, using a key pair you specify during the creation process. You can modify or add other users if needed, but the default user ensures initial access and is a standard part of EC2 instances.
Here are the default users for some common Amazon Machine Images (AMIs) in AWS EC2:
Amazon Linux 2 – ec2-user
ssh -i generated-pem-file.pem ec2-user@ec2-public-ip-address
Amazon Linux 1 – ec2-user
ssh -i generated-pem-file.pem ec2-user@ec2-public-ip-address
Ubuntu – ubuntu
ssh -i generated-pem-file.pem ubuntu@ec2-public-ip-address
Debian – admin or debian
ssh -i generated-pem-file.pem admin@ec2-public-ip-address
CentOS – centos
ssh -i generated-pem-file.pem centos@ec2-public-ip-address
Red Hat Enterprise Linux (RHEL) – ec2-user
ssh -i generated-pem-file.pem ec2-user@ec2-public-ip-address
SUSE Linux – ec2-user
ssh -i generated-pem-file.pem ec2-user@ec2-public-ip-address
Fedora – ec2-user
ssh -i generated-pem-file.pem ec2-user@ec2-public-ip-address
Windows Server – Administrator (for Windows instances)
These are the typical default usernames for each AMI.