Page 1 of 1

Unable to establish SSH Connection

Posted: Mon 18 Aug 2008 20:53
by adambsn
My database is on a remote server that I access via an SSH tunnel. The SSH server & the database server are on the same host.

If I use PUTTY with a tunnel configured to forward 3307 on my local machine to port 3306 on the SSH/DB server, and set my connection string as follows, I am able to connect:

user id=myuser;password=mypassword;host=127.0.0.1;port=3307;database=mydatabase

This verifies that both my SSH server & database server are configured correctly and accessible. However, when I try to use the native SSH
support in the MyDirect.Net driver using the following connection string:

user id=myuser;host=localhost;database=mydatabase;protocol=Ssh;ssh host=myserver.mydomain.com;ssh user=mysshuser;ssh password=mysshpassword

I get the following error message:

Can't connect to MySQL server on 'localhost' (10061)

The values myhost, mysshuser, & mysshpassword are set same as in my Putty session which works. SSH port is default (22) in both putty & mydirect. MySQL listens on 3306 (default) on the ssh/db server.

I have tried the following values for the host param in connect string:

localhost, myserver, myserver.mydomain.com, 127.0.0.1.

All give same error.

I have tried explicitly setting SSH port to 22. Same error.

Please advise.

Posted: Tue 19 Aug 2008 08:07
by Daniel Dean
Hey there!

Have u checked the following:
1) "...in order to connect to MySQL server a client must first be authorized on SSH server" ?

2) "...When you create MySqlConnection object you have to add following parameter to connection string: Protocol=SSH" ?

Posted: Tue 19 Aug 2008 12:28
by Shalex
Please, give us information about your SSH server type and its version. We will try to reproduce the error.

Posted: Tue 19 Aug 2008 12:46
by Shalex
Maybe you will find it useful: section "Using Secure Connections" in MyDirect .NET documentation

Posted: Tue 19 Aug 2008 16:13
by adambsn
The host running both the SSH server & the DB is a debian linux box. I believe the SSH server is part of the OS distribution, but I don't have too may particulars beyond that.

I have read the "Using Secure Connections" section of the documentation many times over by now.

Posted: Wed 20 Aug 2008 15:21
by Shalex
We advise you to find out excactly your SSH-server type (SSH-1 or SSH-2).
It depends on OS distribution version (if you have no particulars beyond that).
It can be only SSH-2 to use with MyDirect .NET.
It also can be network or Debian linux problems. In this case contact your administrator.

Problems connecting with SSH con't...

Posted: Wed 20 Aug 2008 16:08
by adambsn
I have confirmed that the server is configured for SSH-2. Below I have pasted a copy of the sshd_config from the server. As you can see Protocol 2 is specified.

Regarding: "It also can be network or Debian linux problems. In this case contact your administrator."

Doesn't the fact, as I stated in my original post, that I can successfully connect using a Putty tunnel with all the exact same user/password/port/etc. pretty much validate that it is NOT a network or server issue?

Thank you for your support on this.

=== BEGIN sshd_config ======
# Package generated configuration file
# See the sshd(8) manpage for details

# What ports, IPs and protocols we listen for
Port 22
# Use these options to restrict which interfaces/protocols sshd will bind to
#ListenAddress ::
ListenAddress 0.0.0.0
Protocol 2
# HostKeys for protocol version 2
HostKey /etc/ssh/ssh_host_rsa_key
HostKey /etc/ssh/ssh_host_dsa_key
#Privilege Separation is turned on for security
UsePrivilegeSeparation yes

# Lifetime and size of ephemeral version 1 server key
KeyRegenerationInterval 3600
ServerKeyBits 768

# Logging
SyslogFacility AUTH
LogLevel INFO

# Authentication:
LoginGraceTime 600
PermitRootLogin without-password
AllowGroups sshlogin
StrictModes yes

RSAAuthentication yes
PubkeyAuthentication yes
#AuthorizedKeysFile %h/.ssh/authorized_keys

# Don't read the user's ~/.rhosts and ~/.shosts files
IgnoreRhosts yes
# For this to work you will also need host keys in /etc/ssh_known_hosts
RhostsRSAAuthentication no
# similar for protocol version 2
HostbasedAuthentication no
# Uncomment if you don't trust ~/.ssh/known_hosts for RhostsRSAAuthentication
#IgnoreUserKnownHosts yes

# To enable empty passwords, change to yes (NOT RECOMMENDED)
PermitEmptyPasswords no

# Change to no to disable s/key passwords
#ChallengeResponseAuthentication yes

# Change to yes to enable tunnelled clear text passwords
PasswordAuthentication no


# To change Kerberos options
#KerberosAuthentication no
#KerberosOrLocalPasswd yes
#AFSTokenPassing no
#KerberosTicketCleanup no

# Kerberos TGT Passing does only work with the AFS kaserver
#KerberosTgtPassing yes

X11Forwarding no
X11DisplayOffset 10
PrintMotd no
PrintLastLog yes
KeepAlive yes
#UseLogin no

#MaxStartups 10:30:60
#Banner /etc/issue.net

Subsystem sftp /usr/lib/openssh/sftp-server

UsePAM yes
=== END sshd.config ===

Posted: Thu 28 Aug 2008 15:43
by Shalex
We are investigating this problem.
You will be notified on results as soon as possible.

Just re-tried latest version (4.85)...

Posted: Wed 05 Nov 2008 22:55
by adambsn
I just downloaded & re-tried with your latest driver, and find that I am still having exactly the same SSH connection issues as before. All details exactly as before (see my previous posts in this thread). Any update on this?

IF I can get SSH to work, I will be buying the driver straight away.

Posted: Wed 12 Nov 2008 15:07
by Shalex
Probably, the mentioned error arises because connection to MySql server via SSH is impossible due to the current SSH configuration. Try checking the settings of the SSH server - the "Allow connection to forwarded ports" option must be enabled. Alternatively, try setting to "yes" the following parameters: GatewayPorts and AllowTcpForwarding.

Please try this and notify us on the results.

We are going in circles

Posted: Wed 12 Nov 2008 15:55
by adambsn
This is a bit frustrating as we appear to be going in circles. We have been down this road already as you will see if you read this entire thread.

To re-iterate: it is simply untrue that my SSH server is misconfigured. I know this to be true because I CAN sucessfully establish a MySql connection to the very same MySql server via the very same SSH server from the very same client WITHOUT using the devart driver. If I use Putty on my Windows client to establish an SSH connection with a tunnel, I am then able to use any MySql client (MySql.com GUI tools, MySql.com .net driver, etc.) to connect to the DB via the SSH tunnel, no problem. Works every time.

While the Putty-based solution is fine for my solo development purposes, it does not work for production since someone or something would have to manually establish the Putty/SSH connection before my web app could connect to the DB.

I was hopeful the devart driver would address this need perfectly with it's built-in SSH support, but so far, I just keep getting told that there must be something wrong with my server config.

Posted: Mon 17 Nov 2008 08:17
by Shalex
When you are connecting with Putty, key authentication is used. But MyDirect .NET allows only password authentication. Please try changing your SSH server configuration - set the PasswordAuthentication option to "yes". Notify us about the results.

Posted: Mon 17 Nov 2008 16:37
by adambsn
Putty supports both key-based & password-based auth. I AM using a password to connect to the SSH server in question.

Posted: Tue 18 Nov 2008 13:04
by Shalex
Please set the PasswordAuthentication option to "yes" and notify us about the results.