Sep 13, 2018

SSH Tunnel with PuTTY

Set up PuTTY to connect to your SSH server but also set the following
(remember to "LOAD" the connection you want to use)
Tunnel settings:
connection | ssh | Tunnels
Source Port: 88 (could be any number you like)
Destination: localhost
Select Dynamic and Auto

proxy setting in browser:
SOCKS Host: localhost
Port: 88
SOCKSv5 (although v4 is ok too) (NOT HTTP, choose socks)
(need to connect to the server from putty to keep the tunnel)

You can add another tunnel to forward to remote MySQL as describe in the following:

Set up the tunnel

Create a session in PuTTY and then select the Tunnels tab in the SSH section. In the Source port text box enter 3306. This is the port PuTTY will listen on on your local machine. It can be any standard Windows-permitted port. In the Destination field immediately below Source port enter This means, from the server, forward the connection to IP port 3306. MySQL by default listens on port 3306 and we're connecting directly back to the server itself, i.e. Another common scenario is to connect with PuTTY to an outward-facing firewall and then your Destination might be the private IP address of the database server.

Add the tunnel

Click the Add button and the screen should look like this,

To use remote database behind firewall in the glassfish of NetBeans, don't use the proxy setting of NetBeans, but instead port forward to remote database, and change the parameter of database connection of Glassfish to the local mapping port.