Score:2

How to access home ssh server from outside via the Internet?

gp flag

I am running ubuntu server 20.04 and out of the blue I am getting operation timeout. I was wondering how can I troubleshoot the issue.

I am using ufw and the connection port is open. so when I use sudo ufw status , it shows me that the port is accessible.

When I run systemctl status sshd I get that the process is active and that sshd is listening to 0.0.0.0 port xx and :: port xx

I can log on to the machine using my user, so the credentials are not an issue here. I am also able to ping the server from another machine and the ping is working well.

Edit: I am able to connect to the server on the intranet, but not from outside. Is there a way for ssh to be blocked from the internet and not from the intranet?

gp flag
The router is serving a website, it is behind a router and the website is functionning. Do you think it might be something in the router?
gp flag
Thank you for pointing this out. It is true, the port is not forwarded on the router. Can you move your comment as an answer so I can mark it as correct?
ar flag
You are welcome. I will write an answer a little later.
ar flag
Click on the gray check mark ✓ next to the answer you think is correct and turn it green ✅. This will mark your problem as solved, and help others.
ar flag
To the admins and close voters, I know this is not strictly an Ubuntu problem. However, it manifests as one to new home Ubuntu users not familiar with some of the networking concepts. I have voted to close similar questions before, but they keep popping back. I think this question deserves a place in this site.
Score:2
ar flag

Port setup

See the Wikipedia on Port Forwarding to learn more about why you need it.

ssh uses port 22 by default. I will assume you have not changed that. If you changed that port, then you will need to make changes in the instructions below accordingly.

Router setup

Make sure port 22 is forwarded to the Ubuntu server's internal IP address in the home router. This will allow anyone from outside the home LAN use ssh to connect to the home computers.

The instructions are router specific and beyond the scope of this answer as it has nothing to do with Ubuntu.

Some routers allow specifying both incoming port (from the Internet) as well as outgoing port (to the internal IP address of the LAN for the Ubuntu server). In that case, you may want to use a different port, say 2200, when you connect from the outside, and setup your router accordingly:

enter image description here

The picture above is just an example. The settings in your router may look different.

If you have changed the default port in /etc/ssh/sshd_config then you will need to set the internal port above to that port, instead of port 22.

To learn how to setup ssh to work within the home lAN, see Connect two computers with SSH in a home LAN

Here is another port forwarding: how to guide for reference.

Hope this helps

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.