将MySQL工作台连接到vagrant时出现SSH问题

时间:2015-04-01 12:11:27

标签: mysql ssh vagrant mysql-workbench

我正在尝试使用MySQL工作台连接到我的流浪MySQL服务器。它显示了一些错误,如图所示。

error screenshot

工作台错误日志粘贴在下面。

17:34:50 [INF][     SSH tunnel]: Existing SSH tunnel not found, opening new one
17:34:50 [INF][     SSH tunnel]: Opening SSH tunnel to 127.0.0.1:2222
17:34:50 [ERR][   sshtunnel.py]: Traceback (most recent call last):
  File "/usr/share/mysql-workbench/sshtunnel.py", line 231, in _connect_ssh
    look_for_keys=has_key, allow_agent=has_key)
  File "/usr/lib/python2.7/dist-packages/paramiko/client.py", line 337, in connect
    self._auth(username, password, pkey, key_filenames, allow_agent, look_for_keys)
  File "/usr/lib/python2.7/dist-packages/paramiko/client.py", line 528, in _auth
    raise saved_exception
AuthenticationException: Authentication failed.
17:34:50 [ERR][     SSH tunnel]: Authentication error opening SSH tunnel: Authentication error. Please check that your username and password are correct and try again.

vagrant up命令输出粘贴在

下面
==> default: Clearing any previously set network interfaces...
==> default: Preparing network interfaces based on configuration...
    default: Adapter 1: nat
    default: Adapter 2: hostonly
==> default: Forwarding ports...
    default: 22 => 6216 (adapter 1)
    default: 22 => 2222 (adapter 1)
==> default: Running 'pre-boot' VM customizations...
==> default: Booting VM...
==> default: Waiting for machine to boot. This may take a few minutes...
    default: SSH address: 127.0.0.1:2222
    default: SSH username: vagrant
    default: SSH auth method: private key
    default: Warning: Connection timeout. Retrying...
==> default: Machine booted and ready!
==> default: Checking for guest additions in VM...
==> default: Configuring and enabling network interfaces...

命令vagrant ssh在终端中正常工作。我在这里做错了什么?

3 个答案:

答案 0 :(得分:6)

如果您运行vagrant ssh-config,它将显示正在使用的密钥。它通常不使用.vagrant.d/insecure_private_key,而是项目目录中的一个键,如.vagrant/machines/default/virtualbox/private_key

如果在MySQL连接面板中指定了该键,则应该能够登录而无需向vm添加其他密钥。

答案 1 :(得分:2)

关于您在评论中提到的错误: 使用ssh时,不要像这样指定端口

ssh 127.0.0.1:2222

您必须使用选项-p

ssh 127.0.0.1 -p 2222

答案 2 :(得分:2)

经过一些谷歌搜索,我通过将我的ssh公钥添加到vagrant authorized_keys文件来实现它。下面的步骤。

  1. generate ssh keys适用于您的计算机
  2. /home/{username}/.ssh/id_rsa.pub文件
  3. 复制您的公钥
  4. 在期刊中打开vagrant ssh
  5. 使用某些编辑器编辑/home/vagrant/.ssh/authorized_keys(例如:nano /home/vagrant/.ssh/authorized_keys
  6. 将您的公钥粘贴到该文件的末尾并保存
  7. 完成!