2 Answers
- Newest
- Most votes
- Most comments
0
- Make sure the security group attached to the instance allows inbound SSH traffic on port 22 from your IP address or network.
- Check if SSH service is running on the instance using
sudo systemctl status sshd
. Restart the service if not running. - Verify network connectivity to the instance - check if you can ping the public IP/DNS from your local machine.
- Check firewall rules on the instance - use
sudo firewall-cmd --list-all
to check if port 22 is allowed. - Generate a new key-pair if using an old one and try connecting with the private key file.
- Try connecting with verbose mode using
ssh -v
to check for any errors.
As you mentioned other OS work, it seems an OS-specific issue.
The fact that other OS instances work but not CentOS in the same subnet/VPC indicates it may be something specific to the CentOS configuration. Carefully check the above points.
0
The error message Error establishing SSH connection to your instance. Try again later. is from EC2 Instance Connect. This comes preinstalled on Amazon Linux and Ubuntu, but not on CentOS, which would explain why you can connect to the other two, but not CentOS https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-prerequisites.html#eic-prereqs-amis
In terms of connecting to the CentOS EC2 with SSH using PuTTY, check that:
- the CentOS instance is up and running and in healthy state, with 2/2 checks passed in the EC2 section of AWS Console
- the CentOS instance has a public IP address
- it's provisioned in a public subnet - that is a subnet whose route table includes a route to an Internet Gateway
- it's associated with a security group that allows TCP port 22 inbound from your IP address (actually, best to allow 22/tcp from 0.0.0.0/0 while you're troubleshooting, and then tighten it up later)
- the default user on CentOS could be
centos
and notec2-user
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/managing-users.html#ami-default-user-names - you're presenting the correct private key in PuTTY
Relevant content
- asked 7 months ago
- asked a year ago
- AWS OFFICIALUpdated a year ago
- AWS OFFICIALUpdated 2 years ago
- AWS OFFICIALUpdated 2 years ago