SSH Tunnel > DB host is not localhost

[expired user #12097]'s profile image [expired user #12097] posted 5 years ago in General Permalink

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

[expired user #12097]'s profile image [expired user #12097] posted 5 years ago Permalink

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's profile image ansgar posted 5 years ago Permalink

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.

[expired user #12097]'s profile image [expired user #12097] posted 5 years ago Permalink

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's profile image ansgar posted 5 years ago Permalink

So, if you allow AllowTcpForwarding, then tunneling works?

[expired user #12097]'s profile image [expired user #12097] posted 5 years ago Permalink

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's profile image ansgar posted 5 years ago Permalink

Oh shit.

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

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