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
ssh: connect to host port 22: Connection timed out

The same If I try IP

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

I can ping IP

PING ( 56(84) bytes of data.
--- 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
Posted Under: Unix Linux
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