SSH connection problem

miked posted 6 years ago in Creating a connection
Plink 0.61 (downloaded from link on SSH Tunnel tab in session mgr)
XPsp3 system running HeidiSQL connecting to a FreeBSD box running MySQL 5.0.77-log

The problem I am attempting to solve is: When I attempt to connect to the ssh host HeidiSQL returns a dialog stating:

SQL Error (2013): Lost connection to MySQL server at 'reading initial communication packet', system error: 2

If I remove the path to the plink.exe location then HeidiSQL will reveal the command it is attempting to run:

plink -ssh user@host.com -pw password -P nonstdport -N -L 3307:host.com:3306

ssh runs on a non-std port, mysql runs on std port 3306

So, to troubleshoot this problem I open an XP cmd window and run the plink command (with the correct params for my server/host/ports) without the -N option everything works fine. I get a shell prompt, can run a command line into mysql, execute any query against the db, logout of mysql, logout of the shell, and get a DOS prompt back

If I run the above command with a -v option from the DOS command line to see the extra output I get:

Looking up host "<host.com>"
Connecting to <ip> port <port>
Server version: SSH-2.0-OpenSSH_4.3
Using SSH protocol version 2
We claim version: SSH-2.0-PuTTY_Release_0.61
Doing Diffie-Hellman group exchange
Doing Diffie-Hellman key exchange with hash SHA-1
Host key fingerprint is:
ssh-rsa 2048 <some key>
Initialised AES-256 SDCTR client->server encryption
Initialised HMAC-SHA1 client->server MAC algorithm
Initialised AES-256 SDCTR server->client encryption
Initialised HMAC-SHA1 server->client MAC algorithm
Using username "miked".
Using SSPI from SECUR32.DLL
GSSAPI authentication request refused
Access denied
Access denied
Sent password
Access granted
Opened channel for session
Local port 3306 forwarding to <host.com>:<port>
Allocated pty (ospeed 38400bps, ispeed 38400bps)
Started a shell/command
Last login: Mon Sep 26 10:34:30 2011 from <ip>

Thought I'd check here first before reporting a bug to see if I've missed something on my end.
miked posted 6 years ago
well, 140 views and not a peep from anybody

how about a different approach - is there a log that exists or that I can turn on to see/expose what Heidi is running into?
ansgar posted 6 years ago
You can turn on debug messages in Tools > Preferences > Logging. But that won't reveal much relevant stuff I'm afraid. I have no clue what's going on here.
janyan28 posted 6 years ago
Hi miked, were you ever able to resolve this problem? I am experiencing exactly the same thing ...
miked posted 6 years ago
nope, have not been able to resolve. will try to have another go at it.

@anse - any chance of adding additional logging to the heidisql code to track the remote ssh processes and help identify the problem area? looks like you have 2 users who would be able to contribute testing/info to help resolve the problem
janyan28 posted 6 years ago
miked, thanks for the update. My problem is identical, except that I had no problems whatsoever until sometime in the last 30 days. Haven't upgraded heidisql ...
ansgar posted 6 years ago
Yes, I'm willing to help out, please tell me what I shall log additionally.
miked posted 6 years ago
anse - not sure what the login negotiation looks like, so by default I'd think that it would be helpful to log everything that heidisql does when trying to ssh connect such as connection config params, any messages, durations if possible - perhaps into an ssh.log file to keep the ssh logging out of the existing log. appreciate you offering to do this
janyan28 posted 6 years ago
@anse - when using plink from the command line, one can specify verbose mode, which returns tons of information, maybe that's what we need here. Let me know if there's anything I can do to help ...
miked posted 6 years ago
enabling -v plink option is a good idea
ansgar posted 6 years ago
Probably I can grab stdOutput from the plink.exe process, using some code from here.
miked posted 6 years ago
just checking in to see if there is any update on this - anything I can provide in the way of help from my end?
ansgar posted 6 years ago
Well, probably file an enhancement request in the bugtracker, as these forum topics are often overseen. However, can take a while before I find the time for this stuff.
miked posted 6 years ago
added issue 2711 to add logging, tried to make it simple to help get it included quickly -- I have 2 remote servers that I support, having the ability to ssh tunnel into them to massage the db would be an epic help

miked posted 5 years ago
have a workaround solution that I'm using, thought I'd document it here in the hopes that it will help others:

ssh -p9999 -f -N -L7777:localhost:3306 mike@server.com
-p9999 is the remote port that you attach to when you connect via ssh client

-L7777 is the new port number on your local box to get to the remote mysql

mike@server.com your ssh username on the remote box, replace server.com with your hostname

when you rework the cmd line above to match your settings fire up a cmd window and paste the command in and hit enter

you should be prompted for your ssh login password, and you'll get back a DOS prompt.

open up Heidi, set the hostname/ip to the new server to be address =, and port 7777, use your msql user and pwd in the main screen, set the network type to tcp/ip.

login and enjoy.

Please login to leave a reply, or register at first.