Home > OS >  ssh: port 22: Connection timed out
ssh: port 22: Connection timed out

Time:12-14

First, good morning. After running a DigitalOcean internet tutorial that taught how to set up a web server with Django, I had problems connecting via SSH, however, the site continues to run and accept HTTPS connections without any obstacles on the web.

To check availability, I pinged [Public IPv4 Address] [Public IPv4 DNS] and got no response. Since my website has a purchased DNS, I tried to ping [my website's private DNS] and also no response.

I researched possible errors and I'm already advancing: My security group has the rules: HTTP 80, SSH 22 and HTTPS 443 with any source of IPv4 released. So much so that I did all the server configuration via SSH.

I had already done this process before and had the same error, but since it was a test server, I didn't pay much attention. But now, after performing a change from HTTP to HTTPS (to make the site secure) it happens again! Here are the tutorials:

Installing the webserver: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-18-04

How to secure Nginx (HTTP to HTTPS): https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04

Any help is welcome and I thank you in advance!

CodePudding user response:

So, in the tutorial (https://www.digitalocean.com/community/tutorials/how-to-secure-nginx-with-let-s-encrypt-on-ubuntu-18-04), in the part "Step 3 — Allowing HTTPS through the firewall", to check the status of the Firewall the following command was used:

$ sudo ufw status

But the output was:

Output:
Status: inactive

To work around this problem, I ran:

$ sudo ufw enable
Output:
Command may disrupt existing ssh connections. Proceed with operation (y|n)? y
Firewall is active and enabled on system startup

However, AWS itself provides a Firewall system in connection permissions of groups related to the instance. That way, I ended up "turning off" SSH and only allowing HTTPS traffic, so my server kept running.

So, summary: I couldn't connect via SSH due to running a manual Firewall that overrode the EC2 Instance's Groups control

Thank you for trying to help me! Success!

  • Related