

There are optional arguments and ssh command line switches.Īn example of that would be create an SMTP local handler to a remote host using REMOTEPORT=25. Here -f indicates to stop before anything is executed (wait) while -N indicates to not execute any command but create on the local machine (where you issue the ssh command) a local port $LOCALPORT which will essentially allow to access port $REMOTEPORT available on.

In our first examples, where to connect is identical to where we want to create a tunnel. The -L does not fully specify what to do - you also need to tell ssh (as usual) where it will connect to create $LOCALPORT::$REMOTEPORT or a gateway server. The middle server name is the remote host or node to which the tunnel will be created. The port number on the left hand-side is the port which is local to the machine where you issue the ssh command and the port on the right hand-side is the port on the remote server. L is the option allowing to create a tunnel. The syntax used to create tunnels is not always immediate so, through examples, we will carefully go through options and syntax.īasic syntax - simple tunnels to a remote service (1 or 2 HOPS) illustrated General syntax: % ssh 1 HOP syntax (only one remote host is involved) Other use may be to run a service as if you were "inside" a network. For example, tunnels made through gateways may allow you to access an internal Web server while you are on a Wireless or create a local port allowing you to print to a printer only available on a specific network to which you have no specific access to. Creating SSH tunnels can be a powerful tool in your every day work in an environment where many devices are located in different networks.
