1

One in a while I need to check some data in a MS SQL Server in another location.
As for now this requires making database backup, moving it to another server so I can download the .bak file and recover on my local machine. But the database is growing so this is starting to be a pain.

Is it possible (and how?) to make a tunnel Win 7 -> Linux -> Windows Server 2008 with SQL Server for MS SQL Management Studio?
Linux and Windows Server are on the same network at the other location. Only the Linux server is visible externally.

Unfortunately I cannot make any changes on any machine.
I tried with SSH tunnel via Putty, but failed.

chutz
  • 7,888
  • 1
  • 29
  • 59
cichy
  • 113
  • 5

4 Answers4

4

On win7 machine, open putty and set the following settings for the linux ssh session: Connection->SSH->Tunnels->Source port: 1433, Destination: 192.168.0.3:1433, select local radio button.

Now you should be able to connect to localhost:1433 from the win7 machine.

FINESEC
  • 1,371
  • 7
  • 8
  • Almost working, im getting Error 10061 which is "Could not connect to TCP error code 10061: No connection could be made because the target machine actively refused it.". Will check this later. Thanks – cichy Nov 06 '12 at 12:57
  • Would have been nice to hear why it wasn't working earlier and how it was fixed... – Tomislav Nakic-Alfirevic Jul 27 '13 at 12:00
0

Yes, it should be possible. Take a look here, for example. You would need to provide some more information if you need help setting up the tunnel.

claasz
  • 510
  • 3
  • 11
0

Hmm if you can add new rule to iptables to linux server then you can accomplish this by simple port forwarding. But be aware that this is very dangerous because you will make your database visible from internet. Ofcourse you can enable port forwarding only when you need to connect to database server and use some none standard port. This is the rules that you must put in iptables on linux machine:


-A PREROUTING -p tcp -m tcp -s IPOFYOURNETWORK --dport PORTNUMBER1 -j DNAT --to-destination IPOFDATASERVER:PORTNUMER2
-A POSTROUTING -d IPOFDATASERVER -j MASQUERADE

IPOFYOURNETWORK is ip of network or computer that you will try connect from

PORTNUMBER1 is port that you want your database to be visible for you (you can set up some none standard port)

IPOFDATASERVER:PORTNUMER2 it's ip and port of your database server.

B14D3
  • 5,188
  • 15
  • 64
  • 83
0

Following the FINESEC's comment you could get the "connection actively refused" error.

I managed to solve it with checking the "Local ports accept connections from other hosts" and "Remote posrts do the same" checkboxes in Putty under Tunnels. In case someone finds this useful.

Mathew
  • 123
  • 1
  • 4