How to Create a Reverse SSH Tunnel

From RidgeRun Developer Wiki
Revision as of 23:20, 10 November 2021 by Asolis (talk | contribs)

Introduction

Oftentimes, a remote device needs to be accessed through SSH but it's not reachable due to network conditions, security requirements, etc.

SSH Connection Blocked

A reverse SSH tunnel is a solution to that problem. Basically, the hard-to-reach device will create a tunnel to a specific device we have access to. From now on, we will use the following notation:

  • LOCAL Device
The device to which we have easy access (your laptop, for example).
  • REMOTE Device
The device that is hard to access (usually it's far away from us, or it's someone else's device).

The following diagram represents the LOCAL device to the left, the REMOTE device to the right, and the tunnel enabling the connection.


SSH Reverse Tunnel Diagram

Actually the tunnel is created by the REMOTE device, and the LOCAL device uses that tunnel to access the REMOTE. Then, to create the tunnel, you need some level of access to the REMOTE device, but this process is done only once, whether you need to move to the REMOTE or you need the REMOTE owner's help.

Instructions

Now you will find instructions to create a reverse SSH tunnel.


Create Key Pairs

On REMOTE