SSH Tunnel Issue & Port Forwarding !!

Dec 17, 2014 at 6:48 PM
Edited Dec 17, 2014 at 7:13 PM
Hello there to all !

I have a wierd issue which i do not know how to handle it and thus i am asking your help !

I am using the renci.ssh library for using mysql through ssh tunnel
When i use the tunnel with the mysql server in then local network the connection is working fine !
When i change settings try to use it though the network it does not work and thus it works only if i specify in both host and bound hosts parameters !

Below is my code in both ways !

Local Network

mvarSSH.AddForwardedPort(New Ssh.ForwardedPortLocal(System.Net.Dns.GetHostName.Trim, 3306, mvarSSH.ConnectionInfo.Host.Trim, 3306))

Internet Version

mvarSSH.AddForwardedPort(New Ssh.ForwardedPortLocal("", 3306, "", 3306))

Is there any special behavior when it is on the Internet or In the Local Network ? Why it has to be setted in both parameters in

I have to mention that with PLink works fine in both cases !
Dec 18, 2014 at 8:16 AM
Please paste your plink command.
Whats the reason you don't want to use localhost?
Dec 18, 2014 at 8:34 AM
1st thanks for the anwser and helping me !

Well security reasons in the 1st place and in the 2nd from the app settings i have the ip of the ssh server which is the same with the mysql ...
And in the local version of the code the localhost or does not work

Let me later give you the plink command !
Dec 18, 2014 at 8:58 AM
For Security reason you should use "".

First: No DNS envolved, nobody can redirect localhost or your hostname to his IP (DNS-Spoofing)

Second: Your MySQL server is just forwared to your local machine, nobody in the same network can use your local forward.
You can configure your MySQL server to listen on (not reachable from outside) and forward it to your Workstation
to (also not reachable from outside).

Please ensure your MySQL server listens on 3306.
Can be cecked on Linux with:
netstat -ant | grep 3306
And your windows firewall does not block the connection to
Dec 18, 2014 at 9:07 AM
Found something on the local mysql server that maybe the error... Testing it and come back !
Maybe somehow you are right

Something else pleaseeeeeeeeeee

Some other questions regarding the tunnel :
  1. How can i enable compression over ssh tunnel ? Haven't able to find it ...!
  2. I have enabled on mysql compression..Will i have overhead if i enable the compression on the tunnel too... ? I have also some photos i am uploading from the tunnel that is the main reason i need compression .... The photos are jpg or sometimes some pdf files (not photos)
Dec 18, 2014 at 9:11 AM
Edited Dec 18, 2014 at 9:13 AM
Compression support is a planned feature in the future.
There is a way to enable it yourself, but I don't know the details.

If you talk directly to your MySQL server with compression support, you don't need to change anything in the SSH connection/ forwarding.
It just forwards the TCP packets, so the compression already happened.
Dec 18, 2014 at 9:21 AM
After searching the local my.cnf found that it was a misconfiguartion of the mysql server that caused him to be bound on a specific ip !
Changed that and worked like a charm !

So issue is over...

Thanks for all the info !
Dec 18, 2014 at 9:28 AM
Cool! No problem! And have fun with SSH.NET :)
Dec 18, 2014 at 9:42 AM
I have been using SSH.NET for more than 1 year with success ...But lately i need to use ssh tunnels for using the mysql server...

You have done a great job !