Issues SSHing between two Amazon EC2 instances of same region in different availability zones

2

I’m using two Amazon EC2 classic micro instances (A & B) of same region in different availability zones. I’m trying to connect the instances using SSH. Every time while I’m trying to connect, it is showing the error:

connect to host 172.x.x.x port 22: Connection timed out.

I have given the SSH access in security groups to the instances (A & B).

I’m able to connect the instances (A & B) from different servers using SSH.

I have tried the following commands on both the instances(A & B):

Instance A:

  • ssh -i path-to-key.pem user@private-ip-of-B
  • ssh -i path-to-key.pem user@public-ip-of-B

Instance B:

  • ssh -i path-to-key.pem user@private-ip-of-A
  • ssh -i path-to-key.pem user@public-ip-of-A

Please let me know where I’m going wrong.

Bhargava Rama

Posted 2015-09-21T07:33:17.727

Reputation: 21

1Can you ping between hosts? – Linef4ult – 2015-09-21T07:37:53.393

Answers

0

ping may not work if ICMP is disabled (typically it is). Please make sure that

  1. Your security groups are configured correctly
  2. The PUBLIC KEY you're using is in both target user's ~/.ssh/authorized_keys
  3. You either have the same UID already created on the instances. If not, you need to connect as ec2-user with a command similar to this

    ssh -i path-to-key.pem ec2-user@private-ip-of-A

SaxDaddy

Posted 2015-09-21T07:33:17.727

Reputation: 3 181