I m having trouble connecting to amazon ec2 instance using ssh. The key pair matches. On google-ing a bit i find that username is not the same for all instances. I assumed its always ec2-user. How can I find the username of the instance that I have launched?
I am getting this error:
Permission denied (publickey).
on trying this:
ssh -i test-instance.pem [email protected]
Any help will be appreciated.
You can use EC2 Instance Metadata Query Tool which is a simple bash script that uses curl to query the EC2 instance Metadata from within a running EC2 instance as mentioned in documentation. now run command to get required data.
On the Home page, select DB Instances. The Instances page opens. Filter for the DB instance that you want the ID for. The instance details page opens and displays the ID.
Description-
Each Linux instance launches with a default Linux system user account. The default user name is determined by the AMI that was specified when you launched the instance. For Amazon Linux 2 or the Amazon Linux AMI, the user name is ec2-user. For CentOS, the user name is centos. For Debian, the user name is admin or root. For Fedora, the user name is ec2-user or fedora. For RHEL, the user name is ec2-user or root. For SUSE, the user name is ec2-user or root. For Ubuntu, the user name is ubuntu. Otherwise, if ec2-user and root don't work, check with your AMI provider.
Amazon AWS has listed default usernames here:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With