简体   繁体   English

mysql 无法连接 SSH 隧道 -> 拒绝“无”访问

[英]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.我有一台只能通过 SSH 访问的服务器,我在这台服务器上安装了 MySQL。 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.并创建了一个远程用户,以便我可以使用 mySQL 工作台进行开发,但是当尝试使用 MySQL 工作台 GUI 进行 SSH 时,我收到以下错误:无法连接可以继续公钥的 SSH 隧道身份验证。

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.我在连接到 MySQL 时遇到了类似的问题,并想分享我的解决方案,以防其他人在这里结束。

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).场景一:我使用服务器生成的私钥成功访问了 MySQL 数据库(我使用的是 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.场景二:我尝试使用 OpenSSH 生成的私钥访问 MySQL 数据库。 I set the location of the key to C:/Users/username/.ssh/id_rsa and received the error.我将密钥的位置设置为 C:/Users/username/.ssh/id_rsa 并收到错误消息。

The solution here was to convert the OpenSSH private key to an RSA private key.这里的解决方案是将 OpenSSH 私钥转换为 RSA 私钥。

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.确保事先备份您的 OpenSSH 私钥,因为这将覆盖 id_rsa。

I was then able to connect to the MySQL server using the RSA private key.然后我能够使用 RSA 私钥连接到 MySQL 服务器。

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.它将显示 OPENSSH 或 RSA。

For those who, like me, were trying to connect through a SSH key generated by PuTTY:对于像我一样尝试通过 PuTTY 生成的 SSH 密钥进行连接的人:

  1. Open the private key with PuTTYGen.使用 PuTTYGen 打开私钥。 It'll ask for the private key password.它会询问私钥密码。
  2. Go to Conversions->Export OpenSSH Key menu. Go 到 Conversions->Export OpenSSH Key 菜单。
  3. It'll ask for the file name to assign to the converted OpenSSH key.它会要求将文件名分配给转换后的 OpenSSH 密钥。 Give it a different name than the PuTTY private key one you started with.给它一个不同于你开始使用的 PuTTY 私钥的名称。
  4. In MySQL Workbench use the converted key as "SSH Key File".在 MySQL Workbench 中,使用转换后的密钥作为“SSH 密钥文件”。 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.对我来说,实际上反之亦然——我的密钥是 RSA 私钥,必须将其转换为 OpenSSH。 Then MySQL Workbench connected successfully.然后 MySQL Workbench 连接成功。 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!就我而言,当我 select id_rsa.pub而不是id_rsa时出现问题,所以当我 select id_rsa问题消散时!

I had to remove the passphrase from my key file to allow MySQL Workbench to use it.我必须从我的密钥文件中删除密码以允许 MySQL Workbench 使用它。

For my case using with mysql workbench 8.0 required new openssh key format.对于我使用 mysql 工作台 8.0 的情况,需要新的 openssh 密钥格式。 so when you generate openssh format.所以当你生成openssh格式时。 Make sure you generate new format and then provide that key for sshkey确保生成新格式,然后为 sshkey 提供该密钥

For me, this had to do with user:group.对我来说,这与 user:group 有关。 Instead of having the file as root:root, I did a chown to localuser:localuser and it worked fine.我没有将文件设置为 root:root,而是对 localuser:localuser 执行了一次 chown,它工作正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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