1

I can't ssh into my home server outside of my home connection.
(Notice that connected to my wifi, the same which is connected my server, and ssh into my server's local ip I've success).

On my server runs Ubuntu 20.04 (stable version) and the current SSH version is "OpenSSH_8.9p1 Ubuntu-3, OpenSSL 3.0.2 15 Mar 2022" and It runs on port 22(as default setting). I allow the port 22 from Anywhere in ufw setting and I apply it. On my router settings I set port mapping rule the forward the request on port 2200 to my local server throw MAC address(I've read that Ip may change) of my server on port 22(the port upon which runs ssh service).

This are my router map settings: My router settings;

Here there is a translation: "abilitato" -> "enable" , "Qualsiasi host tutte le interfacce" -> "Any host all interfaces"

When I try to ssh with ssh my_user@my_router_ip -p 2200 in my terminal (I tried with macOS terminal and WebSsh on iPadOS) the request starts but after a few minutes ssh fails with a timeout error.

What I'm doing wrong? Thank you

Danatela
  • 13,243
  • 11
  • 45
  • 72

1 Answers1

1

My_router_ip is your local address (192.168...) which is unreachable from the outside.

The outside IP address is set by your provider and usually changed after 24h.

So you you have to find out your "external" ip address first - which is not really feasible given you are not at home.

You should use a dynamic DNS service (look for a Dynamic-DNS-Service in your country) that connects with your box (a "Fritzbox" has a DynDNS setting). You'll get an url which will ma to your external IP and your ssh should look like this:

ssh my_user@someDynsName -p 2200 

You should be aware that you'll open your firewall to the world. Make sure the receiver of the open port is hardened.

More infos from help.ubuntu

kanehekili
  • 6,402
  • Where i can found my external ip and how i can open my firewall to the world? – carbonedavidee Dec 19 '22 at 22:44
  • As I said: depends on your external service which you have to choose and your router. There are many ways how to get your external IP (using dig, curl etc), But that's what this forum is for: it has millions of answers, you just need to look for them. Go to the searchbar above and type display my public IP and you'll find this – kanehekili Dec 20 '22 at 00:05
  • I use No-Ip as DNS service and everything works. Thank you for the help – carbonedavidee Dec 20 '22 at 16:59