How to find your EC2 username
Your EC2 username is the account name you use to log into your Amazon EC2 instance — the virtual server you're renting from Amazon Web Services. If you set up the instance yourself, you chose this name. If someone else set it up for you, they may have used a default name or a custom one. The way you find it depends on whether you still have access to the instance and what operating system it's running.
The fastest method is to check your AWS console, where the instance details often show the username you used during setup. If that's not there, you can connect to the instance and check the system files directly. On Linux instances, this takes a few commands. On Windows instances, you can view it through the Remote Desktop connection settings or the Systems Manager Session Manager.
Key Takeaways
- Check your AWS Management Console first — the instance details or your setup notes may already have the username recorded.
- On Linux instances, you can connect via SSH and run the whoami command to see the current user, or check the /etc/passwd file to see all users on the system.
- On Windows instances, use Systems Manager Session Manager or Remote Desktop to view the username in the connection settings or user account properties.
- If you cannot connect to the instance at all, you may need to stop the instance, detach the root volume, and attach it to another instance to read the configuration files.
- The default username varies by image: ec2-user for Amazon Linux, ubuntu for Ubuntu, admin for Debian, and Administrator for Windows.
Check the AWS Management Console first
Open the AWS Management Console and go to the EC2 dashboard. Find your instance in the list and click on it to open the details panel. Look for tags or descriptions you may have added when you created it — many people include the username in a tag or note. Check the "Details" tab for any information you recorded at launch time.
If you have access to your AWS account history or CloudFormation templates, those may also show the username. CloudFormation templates in particular often include the username as a parameter or in the user data script that runs when the instance starts.
Connect to a Linux instance and check the system
If you have SSH access to your Linux instance, you can find the username directly. Open your terminal or SSH client and connect to the instance using a key pair you know works. Once connected, type whoami and press Enter — this shows the username of the account you're currently logged in as.
To see all user accounts on the system, run cat /etc/passwd. This file lists every user account, and you can identify which ones are regular users versus system accounts. Regular user accounts usually have a user ID (UID) of 1000 or higher, while system accounts are lower. The format is username:password:UID:GID:description:home:shell, so the first field is always the username you're looking for.
Connect to a Windows instance and view the username
For Windows instances, use AWS Systems Manager Session Manager if your instance has the proper IAM role and security group settings. Open the EC2 console, select your instance, and click "Connect" at the top. Choose the "Session Manager" tab and click "Connect." A terminal window opens in your browser. Type whoami to see the current user account.
Alternatively, if you have Remote Desktop access, connect to the instance and open Settings > Accounts. The current user account name appears at the top of the Accounts page. You can also right-click "This PC" or "My Computer," select "Manage," and look under "Local Users and Groups" to see all accounts on the system.
Recover the username if you cannot connect
If you cannot connect to the instance through SSH or Remote Desktop, you can still recover the username by accessing the instance's file system directly. Stop the instance, then detach the root volume (the main storage drive). Attach that volume to another instance you do have access to, mount it, and read the configuration files.
On a Linux volume, mount it and navigate to the etc/passwd file to see all usernames. On a Windows volume, you can read the registry files or user profile folders to identify the account names. After you've found the username, detach the volume and reattach it to the original instance, then start it again.
Default usernames by image type
If you're not sure which username to try, start with the default for your instance's operating system. Amazon Linux instances use ec2-user. Ubuntu instances use ubuntu. Debian instances use admin. Windows instances use Administrator. Red Hat Enterprise Linux uses ec2-user or root. CentOS uses centos.
These defaults are what AWS and the image publishers set up when you launch a fresh instance. If someone customized the instance after launch, the actual username may be different. But if you're starting from scratch and trying to connect for the first time, these are the names to try first.
Frequently Asked Questions
What if I forgot the password but I have the username?
On Linux, you cannot recover a forgotten password, but you can reset it if you have the private key file (.pem) used to launch the instance. Stop the instance, detach the root volume, attach it to another instance, mount it, and edit the shadow file or use a password reset tool. On Windows, you can use EC2Rescue or Systems Manager to reset the Administrator password without knowing the old one.
Can I see the username in my AWS billing or account history?
AWS billing does not record instance usernames. However, CloudTrail logs may show the user data script you provided at launch, which sometimes includes the username. Check CloudTrail in the AWS Management Console under "Event history" and search for the instance ID to see what was configured when it was created.
Is the username the same as my AWS account name?
No. Your AWS account name is separate from the username on an EC2 instance. The instance username is a local account on that virtual server, while your AWS account is your login to Amazon's services. You can have many instances with different usernames all under one AWS account.
What if the instance is running an image I did not create?
Check the image description in the AWS Marketplace or the publisher's documentation. Most public images use standard default usernames — Ubuntu always uses ubuntu, Amazon Linux always uses ec2-user. If the image is from a third party, their documentation should list the default username and how to change it.