Search code examples
amazon-web-servicesamazon-ec2sshconnection

AWS EC2 ssh connection timed out


Running into the dreaded ssh connection timed out error. Current situation:

  1. inbound rule for port 22, open for all IPs and a separate rule just for myIP.
  2. used both public domain name and IP to connect neither works.
  3. No, i did not restart ec2 instance. So public domain and IP has not changed
  4. Turned off Mcaffee firewall on my PC, still nothing.
  5. Used SSHclient extension in chrome, same issue.
  6. Tried AWS SSH Java client, fails to connect with no specific error.
  7. access on private key file is set to 400, as recommended by AWS. I also tried with 777. Neither works
  8. instance status on AWS is good. status check is 2/2.

Output with -vvv flag:

debug1: Reading configuration data /etc/ssh/ssh_config
debug2: resolve_canonicalize: hostname xxx is address
debug1: Authenticator provider $SSH_SK_PROVIDER did not resolve; disabling
debug2: ssh_connect_direct
debug1: Connecting to xxx port 22.
debug1: connect to address xxx port 22: Connection timed out
ssh: connect to host xxx port 22: Connection timed out

Solution

  • Found the issue. Looks like at some point I deleted the default internet gateway. Created a new IG and associated it with the default VPC and added an entry for it in the route table.