Linux Administrator

SSH Tunneling: Local Port Forwarding

In this article I am going to experience the power of the SSH (Seucre Shell) command.

In wikipedia tunnelling is defined as follows:

“In computer networks, a tunneling protocol allows a network user to access or provide a network service that the underlying network does not support or provide directly. – wikipedia”
There are three different types of SSH tunneling and all used for different purposes.

  • Local port forwarding
  • Remote port forwarding
  • Dynamic port forwarding

Each type of tunnel uses an SSH server to redirect traffic from one network port to another. All traffic is sent over the encrypted SSH connection.

Local Port Forwarding

Make Remote Resources Accessible on Your Local System

In this article I am going to focus on local port forwarding. With this method we can access a network that is not accessible directly. For example we have three system:

  • A : Local computer
  • B : SSH server (192.168.0.1:22)
  • C : Web server (192.168.0.5:80)

local-port-forwarding

Let me explain above scenario.

  • Local computer can not access web server directly.
  • Local computer can access only SSH server and SSH server can access web server.
  • Web server is running on port 80 port that needs to be access by Local computer.
  • Port 80 is free on local computer.

Now we want to access the web server from local computer. We can do this using SSH local port forwarding. What we are going to do is forward the traffic form local computer to SSH server then SSH server will forward the traffic to web server. Type the below command to get the work done.

Syntax

ssh -L local_port:remote_address:remote_port username@SSH_server

Command

# ssh -L 80:192.168.0.5:80 [email protected]

After running above command, can access the web server at port 80 at local computer.

Thanks:)

Thank you! for visiting LookLinux.

If you find this tutorial helpful please share with your friends to keep it alive. For more helpful topic browse my website www.looklinux.com. To become an author at LookLinux Submit Article. Stay connected to Facebook.

About the author

mm

Santosh Prasad

Hi! I'm Santosh and I'm here to post some cool article for you. If you have any query and suggestion please comment in comment section.

Leave a Comment