HOW-TO Create a SSH tunnel

First things first: SSH is (very) simply put a secure way to access the command shell from remote servers, because all the communication is encrypted, even the password that you use to connect.
The ssh protocol also allows one to establish a tunnel for communication between two machines, which is also a secure mean of sending information (because is encrypted) or circumventing firewall restrictions in your environment.

The most used options (at least by me) are OpenSSH in *nix environments or in http://cygwin.com/ for Windows. Another option for Windows users is the Putty tool, which provides a UI instead of the traditional ssh command line.

An example of a command line to create a tunnel would be:

$ ssh -l username -L1234:localhost:5678 remoteserver.dyndns.org -p 443

  • -l username is the login name to be used in the connection
  • -L1234:localhost:5678 -L bind_address:host:hostport
  • remoteserver.dyndns.org address of the remote server
  • -p 443 port of the sshd in the remote server; optional and usually is 22

Then, just connect the application you are tunneling to the localhost:1234 port.