Krishna Raj
Krishna Raj

Reputation: 866

SSH issue when connection MySQL workbench to vagrant

I'm trying to connect to my vagrant MySQL server using MySQL workbench. It shows some error as shown in the image.

error screenshot

The workbench error log is pasted below.

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 command output is pasted below

==> 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...

The command vagrant ssh works fine in terminal. What am I doing wrong here?

Upvotes: 3

Views: 2636

Answers (3)

oenpelli
oenpelli

Reputation: 3567

If you run vagrant ssh-config it will show which key it is using. It does not normally use the .vagrant.d/insecure_private_key but a key in the project directory like .vagrant/machines/default/virtualbox/private_key.

If you specify that key in the MySQL connection panel you should be able to logon without having to add another key to the vm.

Upvotes: 9

Krishna Raj
Krishna Raj

Reputation: 866

After some googling, I got it working by adding my ssh public key to vagrant authorized_keys file. Steps Below.

  1. generate ssh keys for your machine
  2. copy your public key from /home/{username}/.ssh/id_rsa.pub file
  3. open vagrant ssh in termial
  4. use some editor to edit /home/vagrant/.ssh/authorized_keys(eg: nano /home/vagrant/.ssh/authorized_keys)
  5. paste your public key to the end of that file and save

done!

Upvotes: 2

Martin Kalcok
Martin Kalcok

Reputation: 157

Regarding error you mention in comments: When using ssh you don't specify port like this

ssh 127.0.0.1:2222

You must use option -p

ssh 127.0.0.1 -p 2222

Upvotes: 2

Related Questions