Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

AWS ssh access 'port 22: Operation timed out' issue

I can't access to AWS EC2 instance from one day.
(AMI: ubuntu/images/ebs/ubuntu-precise-12.04-amd64-server-20121001 (ami-22ad1223))

$ ssh -v -i mykey.pem [email protected]
OpenSSH_5.9p1, OpenSSL 0.9.8x 10 May 2012
debug1: Reading configuration data /etc/ssh_config
debug1: /etc/ssh_config line 20: Applying options for *
debug1: Connecting to xxx.xxx.xxx.xxx [xxx.xxx.xxx.xxx] port 22.
debug1: connect to address xxx.xxx.xxx.xxx port 22: Operation timed out
ssh: connect to host xxx.xxx.xxx.xxx port 22: Operation timed out

This is my "Security Groups" setting in EC2.
I did not change the setting from the time had a good connection.

Ports  Protocol  Source
22      tcp     0.0.0.0/0
80      tcp     0.0.0.0/0
3000    tcp     0.0.0.0/0
3006    tcp     0.0.0.0/0

I've tried many times to restart the server.
Web server is going well. However SSH connection is not.

What could be problem and how to make it work?

like image 926
QHH Avatar asked Jul 17 '13 11:07

QHH


People also ask

How do I fix SSH port timed out connection 22?

Incorrect IP address or hostname – The error may be due to a simple typo. Before you check anything else, make sure you're trying to connect to the correct server. Incorrect SSH port number – By default, servers listen for SSH connections on port 22.

How do I fix SSH connection timeout?

The user will require to increase the SSH connection timeout to solve this problem; It can be done in two ways. One way is to set the keep-alive options in the server configuration file, and another way is to set the keep-alive option in the client configuration file.

Why is SSH connection timing out?

This error message comes from the SSH client. The error indicates that the server didn't respond to the client and the client program gave up (timed out). The following are common causes for this error: The security group or network ACL doesn't allow access.

How do you troubleshoot if you Cannot SSH into an AWS instance?

The best way to diagnose an SSH problem is to launch a new instance in the same subnet, using the same security group. If this works, then the problem is related to the original instance. The fact that you are receiving a timeout error indicates that your SSH client has been unable to reach the instance.


1 Answers

My usual checklist:

  • On AWS console: is the Instance up and healthy?
  • Is it in a public Subnet?
  • Does it have a public ip?
  • Does the VPC have an associated Internet Gateway?
  • Does it have the Routing Table to the Internet Gateway? (Attached to the subnet?)
  • Are the Network ACL rules default?
  • Does the Security group allow ping? If yes, does the ping work?
  • Does the Security group allow SSH inbound?

If there is still no clue, then fire up a new instance (from a base AMI) in the same VPC. Connect to it via SSH. If it was successful, try to ssh from that instance.

like image 91
Adam Ocsvari Avatar answered Nov 04 '22 09:11

Adam Ocsvari