Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Unable to connect to amazon EC2 instance via PuTTY

I created a new instance of Amazon EC2 in Amazon Web Services (AWS) by referring to the documentation. I even added a SSH rule like this:

Port: 22  
Type: SSH  
Source: <My IP address>/32

I downloaded the .pem file, converted it into .ppk file by using PuTTYGEN. Then I added host name in PuTTY like this:

ec2-user@<public_DNS>

I selected default settings, added that .ppk file to PuTTY, logged in and I got this error:

PuTTY error

Even trouble shooting link didn't help me.
I'm also getting this error in system logs:
img1

How can I connect to my Amazon EC2 instance via PuTTY?

like image 360
Ajay Kulkarni Avatar asked Oct 14 '15 12:10

Ajay Kulkarni


People also ask

Why is my EC2 instance not connecting?

The following are common reasons why EC2 Instance Connect might not work as expected: EC2 Instance Connect doesn't support the OS distribution. The EC2 Instance Connect package isn't installed on the instance. There are missing or incorrect AWS Identity and Access Management (IAM) policies or permissions.

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.


2 Answers

Things to check when trying to connect to an Amazon EC2 instance:

  • Security Group: Make sure the security group allows inbound access on the desired ports (eg 80, 22) for the appropriate IP address range (eg 0.0.0.0/0). This solves the majority of problems.
  • Public IP Address: Check that you're using the correct Public IP address for the instance. If the instance is stopped and started, it might receive a new Public IP address (depending on how it has been configured).
  • VPC Configuration: Accessing an EC2 instance that is launched inside a Virtual Private Cloud (VPC) requires:
    • An Internet Gateway
    • A routing table connecting the subnet to the Internet Gateway
    • NACLs (Network ACLS) that permit through-traffic

If you are able to launch and connect to another instance in the same subnet, then the VPC configuration would appear to be correct.

The other thing to check would be the actual configuration of the operating system on the instance itself. Some software may be affecting the configuration so that the web server / ssh daemon is not working correctly. Of course, that is hard to determine without connecting to the instance.

If you are launching from a standard Amazon Linux AMI, ssh would work correctly anytime. The web server (port 80) would require installation and configuration of software on the instance, which is your responsibility to maintain.

like image 156
John Rotenstein Avatar answered Oct 17 '22 12:10

John Rotenstein


Ajay,

Try this. Go to your VPC dashboard. Click on Network ACLs - on the associated acl, update your Inbound Rules to allow SSH access on port22.

like image 3
AWSshouldbeEasy Avatar answered Oct 17 '22 13:10

AWSshouldbeEasy