Tunneling
To use SSH tunnels, you'll need Putty for Windows, SSH Tunnel Manager on MacOS X, or the plain ssh command on Linux/UNIX. There are also other 3rd party solutions, which may make setting up of SSH tunnel more convenient to you.
Also refer to: enabling Tunneling
Needs a guide on this (finally)
With putty:
- First create you normal SSH connection.
- Go to Connection → SSH → Tunnels.
- Add your ports you like to tunnel.
Source port is the port you will use to connect to. Just pick a free port number for this.
Destination is the port you want to connect to. This is the destination viewed from you SSH session. (use 127.0.0.1)
An example to connect to postgreSQL:
- Source port: 4001
- Destination: 127.0.0.1:5432
Don't forget to click on Add!
Now you connect to 127.0.0.1:4001 on you local machine.
With Plain Old SSH:
A command like this works, here's what the options mean. (Here I'm forwarding port 3306, or mysql)
ssh -2 -f -c blowfish -N -C <username>@<server> -L 3307/127.0.0.1/3306
- -s means ssh 2
- -f means fork (run the command in the background)
- -c blowfish and -C specify what kind of compression and turn on compression
- -N doesn't execute any commands on the remote host
- -L localport:localhost:targetport (localport and localhost are where you want the tunnel to terminate, targetport is the port that the tunnel originates at)
- and somewhere in there you need to include your server and username.