Private SSH connection not connecting to EC2 ?

0

The EC2 instance I made is configured with VPC, Subnet, Security Group with permissions ( All traffic ) for SSH and a User with the necessary permissions to interact with the private EC2. I tried to establish a connection via ssh from the command line ( ssh -i "keypair.pem" ec2-user@myipprivado ) and it doesn't connect? The Key Pair has chmod 400 permission and the connection path is correct, I don't know why I can't establish a connection with the instance ?

asked 10 months ago372 views
3 Answers
0

Are you getting any error message at all or is it just sitting there until timing out?

To be able to connect to the target's private IP, the source must also be in the same VPC. The source must have a security group rule allowing outbound over port 22 to the target's private IP, and the target must have a rule allowing inbound over port 22 from the source's private IP.

If the source & target are in different VPCs then the VPCs need to be peered for the above to work.

If the source is trying to connect over the internet then the target's public IP needs to be used, not the private IP.

Does that make things any clearer?

profile picture
EXPERT
Steve_M
answered 10 months ago
  • I configured outgoing ssh rules for the EC2 remote ip and incoming ssh for the local ip. But it tries to connect and it doesn't show any error message.

  • It's less clear now than it was before.

    The EC2 instance that you are having trouble, from what are you trying to connect to it?

    Are you trying to connect from another EC2 instance in the same VPC?

0

What exact error do you see? Is the instance in public/private subnet?

profile picture
answered 10 months ago
  • It keeps trying to connect until the time expires, it does not show an error. Regarding the instance, it is related to a vpc, also linking the subnet to the vpc.

0

check if you can telnet the 22 port, if not then security group as well if any os firewall like iptables are blocking

sourav
answered 10 months ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions