Unable to establish SSH Connection
Unable to establish SSH Connection
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.
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.
-
- Devart Team
- Posts: 6
- Joined: Mon 18 Aug 2008 07:21
Problems connecting with SSH con't...
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 ===
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 ===
Just re-tried latest version (4.85)...
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.
IF I can get SSH to work, I will be buying the driver straight away.
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.
Please try this and notify us on the results.
We are going in circles
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.
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.