My friends use Ubuntu 16.04 and I use Fedora 27. They're new to Linux, and they ask me for help now and then. Rather than helping them over video calls and stuff, I find it easier to have remote access to their systems via SSH (I've performed this few times when we were connected on the same network, but never when we've been apart). I don't have an internet connection at home. Instead, I turn on my mobile hotspot, and connect my laptop to that. Keeping this in mind, how can I use SSH to login to their systems when we're in two different locations and connected to different networks? (I know I should probably be asking this on the Fedora forums, but I assume that the instructions for Ubuntu and Fedora in this matter will be the same).
If you are on two different locations (assuming two different public IP Addresses), Remote User's Router have to have an entry for
port forwarding from
source port any -> 22 or
source port 22 -> 22 for the Linux Host (hostname or IP Address). Assuming the linux host is accepting ssh connection at
port 22 or use whichever port is configured for ssh.
Whenever you will try to
ssh using their Public IP Address, their router will accept the request and based on the port forwarding entry, packet will be destined to the correct host (linux host). In this scenario, your public IP Address does not matter. Either you obtain it using Hot Spot or anything else. As long as you have access to the internet, you should be able to SSH using their Public IP Address or
DNS namespace if using DDNS
If you do SSH too often and dealing with the public IP Address seems to much each time, there are numerous free
DDNS services you can take the benefit from. One of these is called NOIP and instructions to run on linux can be found in here
please remember that exposing ssh to the internet carries a great risk of getting hacked. Therefore I would recommend to go with pa4080's advice and go for TeamViewer or VNC Connect or such.
If You want to work remote on another system consider setting up a dedicated VPN between the two hosts (or their respective gateways like DSL Router)