Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mysql could not connect the SSH tunnel -> access denied for 'none'

I have a server which I can only access via SSH, I have installed MySQL on this server. And created a remote user so I could develop using mySQL workbench, but when try to SSH using MySQL workbench GUI I get the following error: Could not connect the SSH tunnel Authentication that can continue public key.

I'm able to connect to the user from the server itself and that works without any problems, I've checked the privileges and remote access seems to be activated for this user:

+------------------+-----------+
| user             | host      |
+------------------+-----------+
| developer        | %         |
| mysql.infoschema | localhost |
| mysql.session    | localhost |
| mysql.sys        | localhost |
| root             | localhost |
+------------------+-----------+

I've filled in the following:

SSH Hostname <server-IP>
SSH username root
SSH password <clear>
SSH Key File <privat key file>

MySQL Hostname 127.0.0.1
MySQL Server Port 3306
Username <user>
Password <password>
Default Schema <empty>
like image 974
arrayZero Avatar asked Dec 04 '20 14:12

arrayZero


3 Answers

I had a similar issue connecting to MySQL and wanted to share my solution in case anyone else ends up here.

The issue occurred in two different scenarios.

Scenario one: I gained access to the MySQL database successfully using a private key generated by my server (I am using CPanel). I deleted the corresponding public key (mistakenly) from my server then tried to re-connect and received the error.

The solution here of course was to regenerate the keys.

Scenario two: I try to access the MySQL database using an OpenSSH generated private key. I set the location of the key to C:/Users/username/.ssh/id_rsa and received the error.

The solution here was to convert the OpenSSH private key to an RSA private key.

ssh-keygen -p -m PEM -f C:/Users/username/.ssh/id_rsa

Make sure you backup your OpenSSH private key beforehand as this will override id_rsa.

I was then able to connect to the MySQL server using the RSA private key.

You can distinguish between the two types of keys by viewing them in any text editor and reading the first line. It will say either OPENSSH or RSA.

like image 183
Danbardo Avatar answered Oct 20 '22 21:10

Danbardo


For those who, like me, were trying to connect through a SSH key generated by PuTTY:

  1. Open the private key with PuTTYGen. It'll ask for the private key password.
  2. Go to Conversions->Export OpenSSH Key menu.
  3. It'll ask for the file name to assign to the converted OpenSSH key. Give it a different name than the PuTTY private key one you started with.
  4. In MySQL Workbench use the converted key as "SSH Key File". When asked, enter the private key password.
  5. At this point it should connect.
like image 29
Dario Fumagalli Avatar answered Oct 20 '22 21:10

Dario Fumagalli


For me it was actually vice versa - my key was an RSA private key, and had to convert it to OpenSSH. Then MySQL Workbench connected successfully. I guess whoever has a similar problem it may be wort to try to convert the private key either way.

like image 8
Adam Kiraly Avatar answered Oct 20 '22 23:10

Adam Kiraly