Is production: true
#ssh

Title: Type of SSH Portal Forward (SSH Tunnel)

Created: 3 Apr 2023 Modified: 3 Apr 2023

Description: Learn about SSH port forwarding, a technique used for secure data transfer between devices over the internet. This article explains the two main types of SSH port forwarding - local and remote - and provides a clear visual guide to help understand the different accessibility zones for each type. Discover how you can use SSH port forwarding to securely forward traffic between devices and improve your network security.



SSH port forwarding, also known as SSH tunneling, is a technique used to securely transfer data between two devices over an insecure network, such as the internet. It does this by creating a secure, encrypted connection between the two devices and forwarding traffic between them through an encrypted tunnel.

Types of SSH Port Forwarding

There are two main types of SSH port forwarding: local and remote. The below venn diagram show four zone A, B, C, and D, which indicating the accessibilty of machine in side the zone. In a SSH connection / tunnel, the SSH Client (We call it A later on) is inside the Zone A (Refers to the hosts that is accisible by A). While the SSH Server (We call it B later on) is inside the Zone B(Refers to the hosts that is accisble by B).

Type Client Server Port Listening On Target Host Expression
Local A B A A (Remark [1]) / B / C ssh -L {A}:{port}:{A/B/C}:{port} {user}@{B}
Remote A B B A / D / ssh -R {B}:{port}:{A/D}:{port} {user}@{B}

[1]: Assume host A is accessible to host B


Local port forwarding allows you to forward traffic from a local port on your computer(A) to a remote host (A / B / C) and port on another computer.

Remote port forwarding allows you to forward traffic from a port of remote Host(B) to a local host (A / D) and port on your computer.