Skip to main content

SSH to AWS Ec2: port 22: Connection timed out [Resolved]

I am trying to ssh(from my Ubuntu 18.04 desktop) to a running EC2 instance

ssh -i /home/miki/pizda/jk/keys/kur/kjam/python-kjam.pem ubuntu@ec2-18-194-207-247.eu-central-1.compute.amazonaws.com
ssh: connect to host ec2-18-194-207-247.eu-central-1.compute.amazonkur.com port 22: Connection timed out

The same If I try IP

ssh -i /home/miki/pizda/jk/keys/kur/kjam/python-kjam.pem ubuntu@18.194.207.247
ssh: connect to host 18.194.207.247 port 22: Connection timed out

I can ping IP

ping 18.194.207.247
PING 18.194.207.247 (18.194.207.247) 56(84) bytes of data.
^C
--- 18.194.207.247 ping statistics ---
544 packets transmitted, 0 received, 100% packet loss, time 556011ms

Why do I have 100% packet loss? How to set security groups? enter image description here What else could cause problems?


Question Credit: MikiBelavista
Question Reference
Asked June 25, 2019
Tags:
Posted Under: Unix Linux
41 views
1 Answers

You probably have a local firewall on the instance - iptables - that blocks your ssh traffic.

You can use AWS Systems Manager and ssm-session to access the instance and then run iptables -I INPUT -j ALLOW and see if you can SSH to it. If it works you can then setup your firewall properly.

Hope that helps :)


credit: MLu
Answered June 25, 2019
Your Answer
D:\Adnan\Candoerz\CandoProject\vQA