How to setup ssh tunnel using Putty

There would be instances where in we do not have direct access to Database server running in an external network, i.e we cannot open connection to the database directly from our local machine .Usually to access these databases we will have to login to another server(Bastion host) thru putty to get access to Database.But what if I want to access the Database instance using a GUI tool like sql developer?
This is where ssh tunneling(also known as port forwarding) would come in handy.

What is Tunneling?

Tunneling allows a network user to access or provide a network service that the underlying network does not support or provide directly.
A tunnel is exactly as the name suggests, a tunnel over SSH on which we’ll forward a specific port. The port will be accessible on your local machine, but will be automatically forwarded to the remote machine so it appears as if you’re remote service (MySQL in this case) is actually local. This doesn’t just have to work with MySQL, it can be used for any TCP based service, such as HTTP on port 80.

How to set up tunneling in putty?

  1. In putty create a session for the server which has access to MySql Server
  2. Add tunneling information by clicking on Tunnels under Connection=>SSH=>Tunnels
    Source port Field: Key in the port on which you want to access the mysql server from localhost(I chose 9999 port).
    Destination Field: Key in the IPAddress of the mysql server with the port Eg :
    Click on Add button
  3. Click on Session(left top) and save.Then open the session.
  4. Now login to the box using putty with appropriate credentials.To connect to the remote mysql server using SQLDeveloper(or any other similar software) we should connect to localhost:9999 .

One thought on “How to setup ssh tunnel using Putty

  1. Frank

    Hey there! I’ve been following your website for
    a while now and finally got the bravery to go ahead
    and give you a shout out from Porter Texas! Just wanted to say keep
    up the excellent job!


Leave a Reply

Your email address will not be published. Required fields are marked *