SSH Tunneling / Port Forwarding / Pivoting /Socks proxy/adb port fwd and some SSH Control Sequences

n00🔑
7 min readMay 12, 2021

Hi readers here we will see how we can tunnel tcp traffic inside ssh session. There are two types of tunneling/forwarding local and remote. In local we expose services running on system accesible to remote server(ssh server) to our local network and in remote we expose services running in local network to a device accesible by remote server(ssh server). I have found a excellent diagram explaining this on stackexchange discussions (https://unix.stackexchange.com/questions/115897/whats-ssh-port-forwarding-and-whats-the-difference-between-ssh-local-and-remot) take a look and you will get more clear picture what is going on here.

NOTE: Please keep in mind for case 2 of both -R and -L options the nearhost or farhost may not exist in same network as of ssh client(-R) or ssh server(-L). the only thing required them to work is that the near/faraway host must be accessible to ssh client(-R) and ssh server(-L).

We will be seeing all this in action with an example(I will try to explain as much I understood rest you may teach me in comment section :)

--

--