Connect Excel to PostgreSQL through SSH Tunnel (Part 1)

This is a solution I managed to cobble together through trial and error and a lot of web searching. The fundamentals will be applicable to any remote database and should save you a lot of time searching.

1) Setup the tunnel with Putty.
Download Putty Here if you need it: http://the.earth.li/~sgtatham/putty/latest/x86/putty.exe

Once installed you need to create a session. It’s important to do this first as putty likes to delete configurations when you change the settings:

Host name will be the remote server that hosts the database: something like www.mywebserver.com

Putty Configure Settings

Putty Configure Settings

It’s good to test this connection before going forward.

Once you have confirmed your connection to be functional you will need to reopen putty and setup your sever connection again. This time give it a name in “Saved Sessions” and click “Save” to store the configuration.

Next navigate to the Tunnels Section of the Connection > SSH menu

Putty SSH Tunnel

Putty SSH Tunnel

This is where you are going to define your local redirect settings:
Source Port is for the port on your computer that will be used for the connection (typically called localhost)
Destination is the location on the remote server that you need to access. For me and for most databases this is going to be localhost again. Be sure to include the port number for the database. PostgreSQL uses 5432 by default. (It’s important to use the default because the excel addin only supports default port numbers) (127.0.0.1 is interchangeable with localhost and just means redirect to the computer I’m on)

Putty Tunnel Setup

Putty Tunnel Setup

Go back to Session and be sure to Save your configurations otherwise they will be lost next time you start putty. Like I said, Putty really likes to delete configurations.

You’ll get this screen to login and once complete your tunnel will be setup!

Putty Login Screen

Putty Login Screen

Continue to Part 2 – Setting up Excel

1 thought on “Connect Excel to PostgreSQL through SSH Tunnel (Part 1)

Leave a Reply

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

This site uses Akismet to reduce spam. Learn how your comment data is processed.