What is a SSH port Forwarding ?

SSH port Forwarding:

  • SSH port forwaring or tunnelling allows you to forward otherwise insecure Tcp traffic inside a secure SSH tunnel from local to destination server.
  • protocols such as FTP,POP3,SMTP,HTTP,TELNET,and others can all be forwarded inside this tunnel.
  • This will provide increased security features such as encryption and authentication that my not otherwise be supported.
  • you must create a new SH connection to established the tunnelling.

Type of SSH port Forwarding?

There are three types of port forwarding mechanisms between local and remote host:

Local port Forwarding: Create a local port that is connected to a remote host:

Remote port Forwarding: Forward a port on a remote server on the internet to a local port.

Dynamic Port Forwarding: ASOCKS client connect via TCP, and indicates protocol the remote socket it wants to reach.

Local Port Forwarding

This allows you to forward port from your localhost server (ssh_client)to a port on target remot server (ssh_server).

The basic syntax would be ssh -L source Host:source port:forward to host :on port connect to host.

Here the frist field sourceHost using which you will connect to the remote host and remoteport

The third field is the forwarThost i.e the server to which you want to forward the request.you can also put localhost in this field (as it is localhost of remothost).

The fourth field is the on port section i.e the port to which the request has to be forward

last provide the server (connect to host) to which you want to create the secure SSH tunel.

local port forwarding with two server

This is the basic and most used local port Forwarding where we forward the traffic on a port 5555 from localhost (server) to 80 port on target host server 3.

in this example i have running on port 80 on server .

i will configure port 5555 to be used to forward the traffic from localhost(server) to server3 on port 80 in secure SSH Tunnel.

Leave a Comment