Hey everyone! I'm having a strange issue with Amazon EC2. I'm trying to launch a t2.micro instance using an AMI with the ID ami-05ccec3207f126458, but every time I attempt to SSH into it, my SSH keys are refused, even though I set them correctly during the launch. I thought maybe I messed up the keys, so I generated a new pair and used the downloaded version without changing anything. However, even with matching fingerprints, I still can't get in. This is my first time facing this problem and I'm at a loss. I've also tried logging in with both ec2-user and centos as usernames. Just an update: I finally solved it thanks to a user; it turns out I needed to use 'cloud-user'!
5 Answers
I would double-check the AMI ID. Sometimes, using the wrong AMI can lead to issues like this. You can refer to the CentOS AWS images documentation for further verification. If you need to check the AMI ID, ensure you're looking in the right place.
Another option could be to use SSM. It's often much more secure than attempting to SSH into instances, and setting it up via cloud-init can streamline your process.
Did you check the permissions on your SSH key file? Sometimes if the permissions are too open, SSH will refuse to use the key.
The issue you're experiencing is most likely due to the user name for that specific AMI. You should be using 'cloud-user' instead of 'ec2-user' or 'centos'. I ran into the same problem when I first started with this AMI. Good luck!
You might want to consider generating ed25519 keys if the problem persists. Some newer instances might require those for proper authentication.
YES! This was the answer! Indeed, trying with cloud-user worked! Thanks!