简体   繁体   中英

Cannot reach amazon EC2 instance from local using SSH

Cannot ssh into Amazon EC2 instance, this seems to be very common problem but I have tried everything suggested in all available documents, anyone else have any idea what is missing from below?

  • Created new EC2 instance and downloaded the .pem file
  • Created a new inbound rule in EC2 instance Security group allow my local IP
  • Created a new inbound rule in EC2 instance Network ACL to allow my local IP
  • Created a new outbound rule in EC2 instance Network ACL to reach my local IP
  • Made sure the VPC route is attached to internet gateway
  • Made sure EC2 instance is attached to correct security group

After all this when I try to ssh from my local machine I'm getting connection timed out ,is there anything else I have to do I have also disabled firewall and tested just incase

ssh -vvv -i key.pem  ec2-user@********
OpenSSH_7.1p2, OpenSSL 1.0.1g 7 Apr 2014
debug1: Reading configuration data /etc/ssh_config
debug2: ssh_connect: needpriv 0
debug1: Connecting to ec2-instance [********] port 22.
debug1: connect to address ****** port 22: Connection timed out
ssh: connect to host ******* port 22: Connection timed out

A timeout is normally an indication that there is no network connectivity. This is almost always related to the Security Group. It the error returns immediately, it means that the instance received, but rejected, the connection. If it takes a long time to respond, it typically means that the request is not reaching the instance.

Some suggestions:

  • Confirm that the instance has been assigned a Public IP address
  • Confirm that the security group is permitting Inbound Port 22 (SSH) for your IP address. In fact, for testing purposes, temporarily allow it from 0.0.0.0/0 just to eliminate one potential cause of the problem.
  • Remove your NACL entries. The default NACL entries permit ALL inbound and outbound access. Your changes might have negatively impacted this.
  • Confirm that the it is a Linux instance (Windows does not support SSH by default)
  • Confirm the instance is in the Public Subnet (the one with your route to the Internet Gateway)

It is possible that your network is rejecting the connection (eg due to firewall rules). Try using a different computer and/or a different network (eg home vs office) to eliminate this as a cause.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM