Ssh to a computer inside an internal network

Posted on

There are times that I want to access to my computer in my laboratory remotely. However, it is inside the lab's internal network. Luckily, There is a gateway that I make a ssh connection to. The simplified scenario is shown below.

|---------|      |-------|      |-----------|
|my laptop|------|gateway|------|my computer|
|---------|      |-------|      |-----------|

To access my computer in the internal network, I can create a tunnel by running this command on my laptop:


This command will create a tunnel that will forward the local port PORT to my computer port 22 (SSH). -N is for not executing a remote command.

After that, I can simply ssh to my computer using the following command:


And that's all.