6

I've just started using Amazon's free trial, and followed the "Launch an Amazon EC2 Instance" guide to set up the t2.micro instance, but I'm having trouble connecting to it over SSH. I've set up the inbound rules for the Security Group as to allow SSH access from my local IP, and tried connecting over Putty and Cygwin+openssh, but both ways fail with a timeout error:

Output of ssh -vvv

$ ssh -i .ssh/aws-general.pem ubuntu@REDACTED.sa-east-1.compute.amazonaws.com -vvvvvvvv
OpenSSH_6.7p1, OpenSSL 1.0.1j 15 Oct 2014
debug2: ssh_connect: needpriv 0
debug1: Connecting to REDACTED.sa-east-1.compute.amazonaws.com [REDACTED] port 22.
debug1: connect to address REDACTED port 22: Connection timed out
ssh: connect to host REDACTED.sa-east-1.compute.amazonaws.com port 22: Connection timed out

How can I get SSH access to my instance?

EDIT: Tried connecting with the Java client and trough a Ubuntu machine, both time out the same way.

inbound rules: ssh: my ip http:anywhere https:anywhere outbound rules: all traffic: anywhere

  • Temporarily disable the firewall on the EC2 host and try, even though you've specified access from your host. – cutrightjm Dec 31 '14 at 9:14
  • @ekaj Trying from another computer: removed all specific inbound rules on the security group, added a "All traffic from Anywhere" rule, still unable to connect. Running with -vvv shows the exact same output (Except for the OpenSSH version). – Kroltan Dec 31 '14 at 12:57
  • @Kroltan Could you please show us your security group rules? Inbound and outbound. – Bazze Dec 31 '14 at 14:20
  • @Bazze Sorry for the late response, new year and all that kept me away from the internet. See edit to the question – Kroltan Jan 2 '15 at 11:59
  • @Kroltan, are you 100% sure that the IP/CIDR in the SSH inbound rule is the actual IP you're trying to connect from? If you change it to 0.0.0.0/0, can you connect then? – Bazze Jan 2 '15 at 14:19
9

After some comment frenzy on the original question, we found the issue by following the AWS troubleshooting guide for timed out connections. This specific issue that @Kroltan had was caused by a missing route in the routing table. By adding a route in the VPC routing table for connecting the subnet with the internet gateway, the issue was resolved.

  • 1
    the same for me, I don't remember that I would play with routes, but solution was to associate subnets with existing routing table. – sodik Jan 21 '15 at 12:40
  • What do you mean by " missing route in the routing table." ?? – Elia Weiss Aug 9 '17 at 16:17
  • 1
    @EliaWeiss For traffic to be able to flow from/to the internet from/to your VPC/subnet you need the routes in your routing tables to be correct. In the documentation I linked there are some steps which helps you verify that you've correctly routes traffic to the internet gateway. – Bazze Aug 9 '17 at 18:06
0

I don't think your TCP handshake is completing. Check firewalls to see if the packets are being allowed in and out. You could do a tcpdump on the server to see if the packet is getting there. Also an

iptables -nvL

May show if your server has the port blocked.

  • How would I run a tcpdump without SSH access? – Kroltan Dec 31 '14 at 12:49
  • @Kroltan You should be able to use the java console EC2 instances provide; it's somewhere on the instance page – cutrightjm Dec 31 '14 at 20:23
  • Can't connect via the Java console. It also times out: "Connection timed out: no further information" – Kroltan Jan 2 '15 at 11:48
  • The server is down, and I'm not able to connect via ssh. How to run that command? – Kiran Reddy Mar 7 '18 at 10:46
0

To add my 2 cents. I was having problem connecting to ec2 from home. What I did was to add my address to the IPTable in the OS (Ubuntu 14.04). Basically

iptables -A INPUT -s *ip.ad.dr.ess* -j ACCEPT 

I hope this help someone.

  • The server is down, and I'm not able to connect via ssh. How to run that command? – Kiran Reddy Mar 7 '18 at 10:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.