I have a button in an app that when pressed will establish a connection with a SSH Server and portforward to a mysql server. The issue is, I can't seem to correctly establish a tunnel connection with the mysql server via SSH.net library. I can however use
the mysql .net library + putty & portforward to establish a mysql connection when the button is pressed.
I believe what the issue is that my connection string for mysql states the Server as localhost, which should be needed to establish a local connection, right? However using SSH.net library PortFowardLocal I believe the boundhost is not needed (which would
be localhost). Of course when I remove the bound host I get a a runtime error.
According to the mysql net documentation a Server needs to be stated in order to connect to a mysql DB.
Sorry code is in VB:
Dim client As New SshClient("IP, 22, "User", "password")
Dim port1 = New ForwardedPortRemote("", 3306, "local IP", 3306)
'Check for Textbox errors
If textBoxEmail.Text.Length = 0 Then
MessageBox.Show("Enter a Email Address", MessageBoxButton.OK)
ElseIf Not Regex.IsMatch(textBoxEmail.Text, "^[a-zA-Z][\w\.-]*[a-zA-Z0-9]@[a-zA-Z0-9][\w\.-]*[a-zA-Z0-9]\.[a-zA-Z][a-zA-Z\.]*[a-zA-Z]$") Then
MessageBox.Show("Enter a vaild Email Address", MessageBoxButton.OK)
'No Textbox errors? Carry on..
'Connect to SSH Server
Catch ex As Exception
loginmsg.Text = "Error! Click (?) for help."
Dim email As String = textBoxEmail.Text
Dim password As String = passwordBox1.Password
Dim connStr As String = "Server=localhost;" & _
"Database=;" & _
Dim connection As New MySqlConnection(connStr)
Catch ex As Exception
loginmsg.Text = "Login Error. Click (?) for help."
Dim cmd As New MySqlCommand("Select * from reg_user where Email='" + email + "' and password='" + password + "'", connection)
cmd.CommandType = CommandType.Text
Dim adapter As New MySqlDataAdapter()
adapter.SelectCommand = cmd
Dim dataSet As New DataSet()
If dataSet.Tables(0).Rows.Count > 0 Then
MessageBox.Show("Please enter existing username/password.", MessageBoxButton.OK)
Thanks for any help!
Jan 3, 2013 at 5:44 PM
Edited Jan 3, 2013 at 6:24 PM
Here is a link of a screenshot of what is going on when i run the app and it cannot connect to the mysql server when using the ssh.net library (WITH CODE ABOVE)
HOWEVER IF I DO NOT USE SSH.NET LIbrary and use putty as my SSH CLIENT with Mysql library I CAN CONNECT. What am I doing wrong?!? THANKS IN ADVANCE FOR ANY HELP! My putty/plink settings: