Bug #49412 Two SSH Tunnels are opened
Submitted: 3 Dec 2009 19:26 Modified: 11 Jan 2010 16:34
Reporter: Kolbe Kegel Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Workbench Severity:S3 (Non-critical)
Version:5.2.11 OS:MacOS
Assigned to: Alfredo Kojima CPU Architecture:Any

[3 Dec 2009 19:26] Kolbe Kegel
Description:
Two SSH tunnels are opened when I open the SQL Editor (or Server Admin, etc.) for a connection that uses SSH to connect to the MySQL Server.

How to repeat:
1) Create connection that uses SSH
2) Open Connection to start Querying
3) Use local OS tools and remote SSH log to confirm that two SSH tunnels are opened.

$  lsof -p 8119 | grep TCP
Python  8119 kolbe    4u  IPv4 0x0a36c680       0t0      TCP 192.168.1.108:60257->remote:ssh (ESTABLISHED)
Python  8119 kolbe    5u  IPv4 0x09139680       0t0      TCP localhost:22205->localhost:60258 (ESTABLISHED)
Python  8119 kolbe   10u  IPv4 0x099166e0       0t0      TCP 192.168.1.108:60259->remote:ssh (ESTABLISHED)
Python  8119 kolbe   11u  IPv4 0x09917304       0t0      TCP localhost:4432->localhost:60260 (ESTABLISHED)

Dec  3 11:20:25 sshd[14018]: Accepted password for kolbe from remote port 60240 ssh2
Dec  3 11:20:25 sshd[14020]: pam_unix(sshd:session): session opened for user kolbe by (uid=0)
Dec  3 11:20:26 sshd[14022]: Accepted password for kolbe from remote port 60242 ssh2
Dec  3 11:20:26 sshd[14042]: pam_unix(sshd:session): session opened for user kolbe by (uid=0)

Suggested fix:
Only one SSH tunnel should be opened. Multiple MySQL connections can be made through a single tunnel.

Preferably, only one SSH tunnel would be created across the entire Workbench application, but at the very least only one SSH tunnel should be created for each feature (SQL Editor, Admin, etc.) utilizing the Connection.
[11 Dec 2009 1:20] Alfredo Kojima
The SSH tunnel manager has been changed so that:
- the same tunnel will be reused for multiple connections to the same SSH server + SSH user + Target MySQL Host tuple. That is regardless of what opens the connections (whether it is the same or multiple SQL editor or reverse engineering connections etc)
- tunnels will be left open unless they are inactive for 1 minute, in that case they will be auto-closed.
[18 Dec 2009 19:17] Kolbe Kegel
Yeah, 5.2.11 still certainly opens two separate tunnels for each instance of SQL Editor...

Python  18179 kolbe    4u  IPv4 0x08f666b0       0t0      TCP 192.168.1.108:49288->remote:ssh (ESTABLISHED)
Python  18179 kolbe    5u  IPv4 0x144ed274       0t0      TCP localhost:24523->localhost:49289 (ESTABLISHED)
Python  18179 kolbe   10u  IPv4 0x07b0ea8c       0t0      TCP localhost:24523->localhost:49290 (ESTABLISHED)
Python  18179 kolbe   13u  IPv4 0x0de3eb4c       0t0      TCP localhost:24523->localhost:49291 (ESTABLISHED)
Python  18179 kolbe   16u  IPv4 0x144f5304       0t0      TCP localhost:24523->localhost:49292 (ESTABLISHED)
[4 Jan 2010 22:20] Alfredo Kojima
That's 2 separate channels for the same tunnel. Each TCP connection (ie, a MySQL client connection) needs its own channel in the SSH tunnel. The same channel cannot be multiplexed between multiple connections. The Query editor requires 2 connections, 1 for work and 1 for control, such as killing connections, fetching list of tables etc.
[4 Jan 2010 23:27] Kolbe Kegel
Alfredo, my apologies... this does appear to be fixed in a newer release. It looks like there is only one SSH tunnel opened. I think I was confused by the fact that I am still prompted to enter my SSH password when I open new connections, even though they do seem to use the existing tunnel. Perhaps that needs to be reported as a new bug.

At any rate, I do believe there was a bug in earlier versions of WB, so this should be closed properly instead of being marked as "Not a Bug".
[5 Jan 2010 1:32] Alfredo Kojima
Fixed to not request for password when a tunnel can be reused.
[7 Jan 2010 13:24] Johannes Taxacher
fix will be included in 5.2.12
[11 Jan 2010 16:34] Tony Bedford
An entry has been added to the 5.2.12 changelog:

Two SSH tunnels were opened for a single connection to an SSH server. The user was also prompted for a password when a new connection was established, even when the existing tunnel was reused.