Mysql – OpenSSH tunnel and connect to MySQL

MySQLmysql-workbenchputtysshssh-tunnel

Hi I'm trying to use PuTTY to open a SSH tunnel and connect to a remote MySQL server.

PuTTY:

  1. Remote SSH Server IP and port

  2. MySQL Port on the remote server

  3. Tunnel: Local address and port on local machine (I have MySQL Server installed locally, so I'm using 3307 and not 3306 on local machine so there is no conflict with local MySQL Server)

enter image description here
enter image description here

Si I click open, PuTTY asks for an username and password which I provide, if the logon is successful PuTTY immediately closes itself with out any messages or errors

putty.log shows this:

=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2017.08.23 07:29:08 =~=~=~=~=~=~=~=~=~=~=~=

login as: myUser
Using keyboard-interactive authentication.
Password for myUser@Server:
Could not chdir to home directory /home/myUser: No such file or directory
This service allows sftp connections only.

Now, If I try to connect with MySQL Workbench using the option Standard TCP/IP over SSH, it works…

enter image description here

I've read in forums that the solution is to tweak the options on the SSH server, but I don't have any control over the SSH Server.

Although I can use WorkBench to connect to the database, the goal here, is to have Putty open the SSH tunnel.

How can I open the SSH tunnel with PuTTY? What am I doing wrong? How can I solve this without altering the server?


Using plink: getting the same result

enter image description here


EDIT

I disabled the Don't start a shell or command at all option as Martin suggested, now I don't receive the SFTP error, but after typing the password nothing happens

The log is just writing what I see in the screen:

=~=~=~=~=~=~=~=~=~=~=~= PuTTY log 2017.08.23 10:07:25 =~=~=~=~=~=~=~=~=~=~=~=
login as: user
Using keyboard-interactive authentication.
Password for user@server:

EDIT 2 – SOLVED

After following Martin Prikryl advice:

I swapped the ports: L3307 -> 127.0.0.1:3306

enter image description here

Putty event Log now says: Access granted - Local port 3307 forwarding to 127.0.0.1:3306

Now MySQL WorkBench is able to connect to 127.0.0.1:3307 successfully

Thanks!

In case you need to do this with PLINK, here is how I did it:

plink.exe SSH_SERVER_IP_OR_ADDRESS -P 2204 -ssh -l USER -pw PASSWORD -L 3307:127.0.0.1:3306 -N -v

Best Answer

Try checking:
Connection > SSH > Protocol options > Don't start a shell or command at all.


You also have a local and remote port of the tunnel swapped (You have 2 and 3 labeled other way around.)

It should be:

L3307 => 127.0.0.1:3306

Check PuTTY event log for details (PuTTY console window title and select "Event log").

Related Question