Reputation: 866
I'm trying to connect to my vagrant MySQL server using MySQL workbench. It shows some error as shown in the image.
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
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
Reputation: 866
After some googling, I got it working by adding my ssh public key to vagrant authorized_keys
file. Steps Below.
/home/{username}/.ssh/id_rsa.pub
filevagrant ssh
in termial/home/vagrant/.ssh/authorized_keys
(eg: nano /home/vagrant/.ssh/authorized_keys
)done!
Upvotes: 2
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