Unable to connect to remote MySQL server via SSH using MySQLWorkbench

Bug #1385147 reported by goodey
154
This bug affects 30 people
Affects Status Importance Assigned to Milestone
mysql-workbench (Debian)
Fix Released
Unknown
mysql-workbench (Ubuntu)
Fix Released
Undecided
Unassigned
Nominated for Trusty by Rolf Leggewie

Bug Description

The exact same configuration works fine in 14.04 but when attempting to connect in 14.10 using the MySQL Workbench 6.1 6.1.7.11891 build 1788, the connection fails with the following error message.

--------------------------
  Your connection attempt failed for user 'XXXXXXXX' from your host to server at 127.0.0.1:3306:
  Tunnel error: Remote connection to 127.0.0.1:3306 failed: AttributeError("'Transport' object has no attribute 'window_size'",)

Please:
1 Check that mysql is running on server 127.0.0.1
2 Check that mysql is running on port 3306 (note: 3306 is the default, but this can be changed)
3 Check the membership-app has rights to connect to 127.0.0.1 from your address (mysql rights define what clients can connect to the server and from which machines)
4 Make sure you are both providing a password if needed and using the correct password for 127.0.0.1 connecting from the host address you're connecting from
---------------------------

Tags: patch
Revision history for this message
Launchpad Janitor (janitor) wrote :

Status changed to 'Confirmed' because the bug affects multiple users.

Changed in mysql-workbench (Ubuntu):
status: New → Confirmed
Revision history for this message
Beltshassar (danieldamm) wrote :

Looks like the bug was fixed in debian: https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=763971

Revision history for this message
goodey (goodey) wrote :

How long before we can expect to see the debian fix make its way to Ubuntu?

Revision history for this message
Mateusz Piątkowski (bananq) wrote :

Did you find any easy workaround except from connecting directly without an ssh tunel?

Revision history for this message
Scott Deagan (scott-deagan) wrote :

@Mateusz Piątkowski (bananq):

You could always try to manually set up a tunnel yourself via the terminal:

1. Open up a terminal.
2. Enter: ssh -L 3307:localhost:3306 <email address hidden>
3. Open MySQL Workbench.
4. Create a new "Standard (TCP/IP)" connection.
5. For the hostname, leave the default: 127.0.0.1
6. For the port: 3307 (assuming you've used 3307 as in my example above).
7. Enter the rest of your MySQL credentials.

Note that I have used 3307 in step 2 above. This would be necessary if you have a local instance of MySQL Server listening on port 3306 (in which case, it would not bind to 3306). If you don't have a local instance of MySQL Server listening on port 3306, you could use:

ssh -L 3306:localhost:3306 <email address hidden>

and then for step 7 leave the default port - 3306.

I haven't tried out the above myself, but I see no reason why it wouldn't work.

Revision history for this message
Andy Turfer (a-turfer) wrote :

Scott's workaround in comment #5 works. If you don't want to remember all those flags and parameters, you can always create an entry in your ~/.ssh/config, like so:

Host mysql.tunnel
  HostName some-ssh-server.com
  User ssh_username
  IdentityFile ~/.ssh/config/id_rsa
  LocalForward 3307 127.0.0.1:3306

(of course you wouldn't need the IdentityFile line if you don't have any public/private keys configured)

Then you could do the following to establish the tunnel:

ssh mysql.tunnel

If you don't want/need to execute commands on the remote SSH server, you could use:

ssh -f -N mysql.tunnel

Then, to close the tunnel:

ps aux | grep mysql.tunnel
kill -9 [insert the mysql.tunnel PID here]

Revision history for this message
Akira Matsuzaki (akira-matsuzaki-1977) wrote :

I've created a small patch for fixing connectivity through SSH tunnel.

This patch is backported from Debian fix.

https://bugs.debian.org/cgi-bin/bugreport.cgi?bug=763971

Original Patch:
http://anonscm.debian.org/cgit/collab-maint/mysql-workbench.git/tree/debian/patches/paramiko.patch?id=206bf85ccc1b884b1542c04aded1cde3998bfa4f

You can apply this patch by following.

cd /usr/lib/mysql-workbench/
patch -p1 < paramiko.patch

Revision history for this message
Ubuntu Foundations Team Bug Bot (crichton) wrote :

The attachment "paramiko.patch" seems to be a patch. If it isn't, please remove the "patch" flag from the attachment, remove the "patch" tag, and if you are a member of the ~ubuntu-reviewers, unsubscribe the team.

[This is an automated message performed by a Launchpad user owned by ~brian-murray, for any issues please contact him.]

tags: added: patch
Revision history for this message
Scott Deagan (scott-deagan) wrote :

Akira Matsuzaki - thanks for the patch, it works.

Revision history for this message
Aaron B. Russell (aaronr) wrote :

Bug also affects Ubuntu 14.04.

Revision history for this message
Steven Azari (stevenazari) wrote :

I get:
patching file modules/wb_admin_ssh.py
Hunk #1 FAILED at 84.
Hunk #2 FAILED at 99.
patch unexpectedly ends in middle of line
Hunk #3 succeeded at 674 with fuzz 1 (offset 36 lines).
2 out of 3 hunks FAILED -- saving rejects to file modules/wb_admin_ssh.py.rej
so needs a re-patch

Revision history for this message
Sin-young "Divinespear" Kang (divinespear) wrote :

paramiko.patch works well. thanks.

Revision history for this message
Giacomo Tazzari (giact) wrote :

I think I experienced this issue on 14.10: when trying to tunnel through ssh, MySQL Workbench was giving me "Lost connection to MySQL server at 'reading initial communication packet', system error: 0"

paramiko.patch solved it for me

Revision history for this message
Stephen (dranger) wrote :

confirming the same issue and successful resolution from comment #13

Revision history for this message
Shai Gluskin (shai-m) wrote :

I'm running Ubuntu 14.10. I installed MySQL workbench from the Ubuntu Software Center. It delivered version 6.1 which has the bug described in this issue. I got the errors described in this issue when I tried to connect over SSH.

The patch did not work for me because the files needing patching were not at the path described in the patch.

My workaround: I just downloaded MySQL Workbench 6.2.5 from the Oracle web site, installed it, and now I can connect to remote MySQL dbs via SSH without any problem.

Here is the link to the MySQL Workbench download if anyone needs it: http://dev.mysql.com/downloads/file.php?id=455789

Revision history for this message
Samuel Martins (samuel-urban) wrote :

Thanks @shai-m, that's the best workauround of them all.

Revision history for this message
Sean (verbgarden) wrote :

Confirming the same issue and successful resolution from comment #13.

Much thanks to the paramiko patch!

Revision history for this message
Adriano Varoli Piazza (adrianovaroli) wrote :

I get the same error as Steven Azari, #11:
$ sudo patch -p1 < /home/[user]/Desktop/paramiko.patch
[sudo] password for [user]:
patching file modules/wb_admin_ssh.py
Hunk #1 FAILED at 84.
Hunk #2 FAILED at 99.
Hunk #3 succeeded at 674 (offset 36 lines).
2 out of 3 hunks FAILED -- saving rejects to file modules/wb_admin_ssh.py.rej

Revision history for this message
Rolf Leggewie (r0lf) wrote :

Does anyone experience this problem in an unpatched version in vivid or later?

The patch from #7 should probably be backported to trusty.

Rolf Leggewie (r0lf)
Changed in mysql-workbench (Ubuntu):
assignee: nobody → Rolf Leggewie (r0lf)
Changed in mysql-workbench (Debian):
status: Unknown → Fix Released
Revision history for this message
FragBis (fabricedant) wrote :

For people having issues with the paramiko.patch it's certainly because you are running on 64 bits OS (I've experienced this issue too on my Mageia, 64 bit version). I've just read the patch and understood what I had to modify.
My solution is for advanced users only (because any changes may cause some bugs).

Backup the original file "/usr/lib64/mysql-workbench/modules/wb_admin_ssh.py" to "/usr/lib64/mysql-workbench/modules/wb_admin_ssh.py.orig", if not done yet:
     cp /usr/lib64/mysql-workbench/modules/wb_admin_ssh.py /usr/lib64/mysql-workbench/modules/wb_admin_ssh.py.orig

Open "/usr/lib64/mysql-workbench/modules/wb_admin_ssh.py" with any editor (as root, or sudoer).

Edit at line 90, just add the following:

            else:
                m.add_int(self.default_window_size)
                m.add_int(self.default_max_packet_size)

Same at line 108 (counting the previous lines you added), just add:

            else:
                chan._set_window(self.default_window_size, self.default_max_packet_size)

That just fixed the problem for me. I relaunched mysql-workbench and could connect my remote server using SSH tunnel as well.

I don't know if this will fix the issues mentionned at #18, but that was the message I had when I tried to patch mysql-workbench.

What I've understood is: the original python script do not handle any "else" case if some conditions are not satisfied at line 88. The patch contains the "else" part that set some default values to some object properties in any case and prevents that annoying bug.

Revision history for this message
FragBis (fabricedant) wrote :

The patch is a "diff" file that upgrade a certain file at a certain version and could not work for many reasons.

I hope that the python developpers from Oracle will fix this for their next version (and let MariaDB being as compatible as possible).

Revision history for this message
Rolf Leggewie (r0lf) wrote :

we still need confirmation if anybody on vivid or a later release is affected

Revision history for this message
alciregi (alciregi-deactivatedaccount) wrote : Re: [Bug 1385147] Re: Unable to connect to remote MySQL server via SSH using MySQLWorkbench

No problem for me on 15.10
On Jan 30, 2016 2:05 PM, "Rolf Leggewie" <email address hidden> wrote:

> we still need confirmation if anybody on vivid or a later release is
> affected
>
> --
> You received this bug notification because you are subscribed to the bug
> report.
> https://bugs.launchpad.net/bugs/1385147
>
> Title:
> Unable to connect to remote MySQL server via SSH using MySQLWorkbench
>
> Status in mysql-workbench package in Ubuntu:
> Confirmed
> Status in mysql-workbench package in Debian:
> Fix Released
>
> Bug description:
> The exact same configuration works fine in 14.04 but when attempting
> to connect in 14.10 using the MySQL Workbench 6.1 6.1.7.11891 build
> 1788, the connection fails with the following error message.
>
>
> --------------------------
> Your connection attempt failed for user 'XXXXXXXX' from your host to
> server at 127.0.0.1:3306:
> Tunnel error: Remote connection to 127.0.0.1:3306 failed:
> AttributeError("'Transport' object has no attribute 'window_size'",)
>
> Please:
> 1 Check that mysql is running on server 127.0.0.1
> 2 Check that mysql is running on port 3306 (note: 3306 is the default,
> but this can be changed)
> 3 Check the membership-app has rights to connect to 127.0.0.1 from your
> address (mysql rights define what clients can connect to the server and
> from which machines)
> 4 Make sure you are both providing a password if needed and using the
> correct password for 127.0.0.1 connecting from the host address you're
> connecting from
> ---------------------------
>
> To manage notifications about this bug go to:
>
> https://bugs.launchpad.net/ubuntu/+source/mysql-workbench/+bug/1385147/+subscriptions
>

Revision history for this message
Rolf Leggewie (r0lf) wrote :

Closing as fixed and nominating for trusty.

Comment directed at comments #15 and #16: Installing third-party software is by far the worst idea of them all. Not "the best workaround of them all". Not. At. All.

Changed in mysql-workbench (Ubuntu):
status: Confirmed → Fix Released
assignee: Rolf Leggewie (r0lf) → nobody
Revision history for this message
AVINASH SHASHIKANT DALVI (aviboy2006) wrote :

Thanks Akira Matsuzaki (akira-matsuzaki-1977). Because of you save my whole day. Its works fine.

To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Duplicates of this bug

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.