简体   繁体   中英

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>

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.

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.

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.

in my case, there was a problem when i select id_rsa.pub instead id_rsa , so when i select id_rsa problem dissaper!

I had to remove the passphrase from my key file to allow MySQL Workbench to use it.

For my case using with mysql workbench 8.0 required new openssh key format. so when you generate openssh format. Make sure you generate new format and then provide that key for sshkey

For me, this had to do with user:group. Instead of having the file as root:root, I did a chown to localuser:localuser and it worked fine.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM