Connect to SQL Server through an SSH tunnel

Posted in Microsoft SQL Server -

I recently needed to connect to a Microsoft SQL Server which I couldn't reach directly, but which is visible from a web facing Linux machine. I've covered how to create an SSH tunnel on Windows with PuTTY already and then it's simply a matter of connecting through the tunnel on the localhost to the SQL Server at the other end.

Change the server name from (local) to 127.0.0.1

The process for creating the tunnel and connecting to the server was relatively straight forward but there was one little gotcha that had me puzzled for a few minutes.

The server name will be (local) by default, as shown in the screenshot below:

sql server management studio - connect to server dialog

I assumed this would connect to the local machine's tunnel and then in turn to the SQL Server at the other end. Unfortunately this wasn't the case, and you need to change the server name from (local) to 127.0.0.1 for this to work.

If you are connecting to a different local port, e.g. 1434 as I did in my earlier post, then set the server name to 127.0.0.1,1434.



Related posts:


Comments