SSH Tunnel > DB host is not localhost

4dventurist posted 3 weeks ago in General

Hi,

This seems to only work if MySQL is reachable at localhost once you SSH in. What if it isn't?

I've tried putting the DB host under Settings > Hostname but that doesn't work for me.

The part of plink.exe that it changes is:

-N -L 3307:<my db hostname here>:3306

Doesn't this have to be localhost? Sorry I'm a little confused on what the -L option does.

Thanks for any help.

Rob

4dventurist posted 2 weeks ago

Maybe I made no sense in my previous post... so here goes again.

Normally this is how I could connect to MySQL on a shared hosting plan

--

My computer --> SSH --> Shared host --> MySQL available on localhost

My scenario with 1 & 1 hosting

My computer --> SSH --> Shared host --> MySQL is only available at db.host.io

--

Will SSH Tunnel work with the later scenario?

ansgar posted 2 weeks ago

From plink.exe output:

-L [listen-IP:]listen-port:host:port
           Forward local port to remote address

You have to enter the remote host in the "SSH tunnel" tab of HeidiSQL. This is what is used between the listen-port: and :port.

Once the tunnel to the remote host is established, HeidiSQL has a hardcoded address of "127.0.0.1" to which it connects.

4dventurist posted 2 weeks ago

OK I think I figured out the problem

On the server in /etc/ssh/sshd_config the following option is set

AllowTcpForwarding no

--

I tried it manually from the command line, then manually did a telnet to 127.0.0.1:3307 and look what happens (see attached)

1 attachment(s):
  • problem
ansgar posted 2 weeks ago

So, if you allow AllowTcpForwarding, then tunneling works?

4dventurist posted 2 weeks ago

unfortunately it's a server setting for sshd so I can't change it, but I believe if I could then it would work.

ansgar posted 2 weeks ago

Oh shit.

In that case I have no clue how to use Heidi then.

Please login to leave a reply, or register at first.