Connect to SQL Server through SSH tunnel?

1

I'll preface this by saying that I'm not familiar with SSH and doing this sort of stuff, so I'm really looking for a whole explanation of how to go about this. I have an idea that I might be able to somehow SSH tunnel into the SQL server, but I'm not sure, and I wouldn't know where to start.

My situation is this: I have a VPN that I log into, which allows me to RDP into one machine, then from there I can RDP into the SQL server, and then I can work on that machine in SQL Management Studio.

So I want to be able to just develop on my machine instead of going through these hoops, but I can't login to the DB in the Management Studio. Is it possible to setup something to be able to do what I want?

Ramon Johannessen

Posted 2017-02-03T19:16:30.510

Reputation: 11

Answers

0

You could try local port forwarding with ssh.

On your local machine: ssh -L port:host:hostport user@RDPmachine

Then, on the RDP machine: ssh -L port:host:hostport user@SQLserver

Connecting to your local machine will then connect to the SQL server.

For instance, if SQL Server is listening on TCP/1433, you could use 1433 for port and hostport, resulting in connections to 127.0.0.1:1433 connecting to the RDP machine (port 1433), which will connect to the SQL server (also port 1433).

If you don't have command line ssh available, most GUI ssh clients can be configured to forward local ports, but it would depend on which client as to how that would be done.

-Rich Alloway (RogueWave)

Rich Alloway - RogueWave

Posted 2017-02-03T19:16:30.510

Reputation: 86

0

This doesn't directly answer your question, but if you're able to open a VPN connection, you can paste this into a command prompt:

runas /netonly /user:DOMAIN\AccountName "C:\Program Files (x86)\Microsoft SQL Server\120\Tools\Binn\ManagementStudio\Ssms.exe"

(Adjust your path accordingly - the above is for the 2014 version of management studio). If I read correctly, you have management studio installed locally, so this should work for you.

Charles Burge

Posted 2017-02-03T19:16:30.510

Reputation: 1 792