Access MS SQL server over SSH.NET

Jan 27, 2012 at 3:10 PM

Hi all,

I try to access a MS SQL 2008 R2 Server over SSH with this library but I have all the time no connection with my program or the SQL Server Management Studio. The forwarded port (local port 11111 and Remote Port 1433 at server is correct (testet with telnet), but no connection with the Managment studio. I have all the time the message that it can´t find the sql server.

I have tested the same settings with putty and it work. I have change the ports in my program for Remote Desktop (RDP) and I can access the terminal server.

I dont know what is wrong. Can me help someone please... Big PLEASE.... Big thanks....

Best regards,


Jan 27, 2012 at 3:41 PM



What line do you execute using putty that it works for you and what code you running that it doesnt?




Jan 27, 2012 at 3:55 PM

Hi Oleg,

I have found the solution self. My fail was in the PortForward command. I have used only this parameters:

port = client.AddForwardedPort<Renci.SshNet.ForwardedPortLocal>((uint)localport, destinationHost, (uint)remoteport);

I think as local server address take the library the name "localhost". This works with RDP but not with the SQL Server connection.

I have changed the line to:

port = client.AddForwardedPort<Renci.SshNet.ForwardedPortLocal>(sourcehost, (uint)localport, destinationHost, (uint)remoteport);

sourcehost is ""

This works with the SQL Management Studio and with my program that connect to the SQL server. The RDP works with this settings too....

Thanks for the quick anwser...

This library is very goood... Thanks.... Can you say when the compression option for the normal ssh connection is built-in?

Best regards,


Jan 27, 2012 at 4:13 PM

Glad it worked out,

as far as compression, I dont have timeline for it or it actually not in my plans right now, its just something I want to do eventually.

The reason its not implemented yet, is because I dont want to introduce any third party dependency here.

But if you really need a compression you can use it, but you will need to modify source code and add third party component like Ionic.Zlib.ZlibStream, which I already tested against and have code commented out.




Jan 27, 2012 at 8:20 PM

Hi Oleg,

thanks for the compression hint. I think I have found the places of the commented out code. I will try this tomorrow. Can I contact you again if I have some question to the compression routine.

I think its a good way to not use third party components. Its good too to try another ways for testing to have a backup solution if the normal way not work...

Thanks again...

Best regards,


Nov 14, 2013 at 2:37 AM
Hi Torakas, can you explain me how to connect to sql server using the library. and tell me about port forwarding.

I need to execute some queries in a server outside our net, i have ssh access and I can query with putty, but I need to query with a vb app.

how I configure sql management studio to use ssh?