EC2 Instance ssh

1

Hello,

I am trying to ssh EC2 instance from GIT bash but getting the error "$ ssh -i "webserver-key.pem" ec2-user@ec2-18-216-146-49.us-east-2.compute.amazonaws.com ssh: connect to host ec2-18-216-146-49.us-east-2.compute.amazonaws.com port 22: Connection timed out"

Also I tried EC2 instance connect and got below error:-

Failed to connect to your instance EC2 Instance Connect is unable to connect to your instance. Ensure your instance network settings are configured correctly for EC2 Instance Connect. For more information, see Set up EC2 Instance Connect at https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/ec2-instance-connect-set-up.html.

Thanks, Monica

Monica
asked a year ago443 views
4 Answers
0

I had to set up a security group that gave inbound and outbound TCP access to all IP addresses and attach it to the Internet Gateway. TBH, I googled the answer.

Also, make sure that the permissions on the SSH Certificate that you copy to your local workstation are set to your account only. In Linux, that's chmod 400 keyfile.pem. In Windows, you have to add your user with Full Access and then disable the inheritance to remove the inherited permissions.

answered a year ago
  • NSG i used default one which allow all traffic. Also user has full access and inheritance disabled. but its giving same error.

0

I found my mistake so i followed the below steps:-

Download putty and puttygen, or the putty package and install it. Get the .pem file from your AWS EC2 instance. Use puttygen to convert the .pem file so that you'll have a private key --- mistake happened here. I chose "Conversions" tab from PuttyGen, and load my .pem file. After loading pem file, here DO NOT hit "Generate", instead directly "Save private key". That's the key you need. If you click Generate, you'll have a totally different pair of keys. In putty, use ec2-user@your.public.dns.that.you.get.from.aws.ec2.instance, and load the private key at SSH/Auth

Thanks,

Monica
answered a year ago
  • That's how I usually connect, but today suddenly I'm unable to connect using Putty with my preset saved connection

0

I tried that myself, but ultimately had to define an explicit one and assign to the VPC for my instance. Also, for SSH, you will need to have an outbound rule on your default Security Group that explicitly allows connectivity to the Ephemeral Ports (1024-65535), as outbound SSH will connect on one of those ports.

In windows, this is viewable using the netstat command, but in Linux netstat is deprecated in favor of 'ss'. Most distributions still install it with the networking tools, but ss is the preferred command.

answered a year ago
0

I'm having the exact same issue. Not sure why this is happening.

Halal
answered a year ago

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.

Guidelines for Answering Questions