0

I’m trying to do ssh-tunnelling via local forwarding to a remote MySQL host reached via a non-standard (port-forwarded) ssh port of 2200 mapped internally to the server’s port 22.

First of all, I know this is possible, because I can configure MySQL Workbench to make such a connection. (MySQL Workbench provides built-in ssh-tunnelling connections). In the configuration of the SSH host I put mysql-server:2200 and configure the rest of the connection normally and it just works.

The problem is when I try to make a permanent ssh tunnel using the non-standard destination port of 2200. The standard command (default port 22) is of the form:

ssh -g -C -N -L 3307:127.0.0.1:3306 mysql-server

I just cannot find the place to put the non-standard ssh destination port. It causes a host key verification error with this form:

ssh -g -C -N -L 3307:127.0.0.1:3306 -p 2200 mysql-server

It gives a non-resolvable destination host with this form:

ssh -g -C -N -L 3307:127.0.0.1:3306 mysql-server:2200

It give a connect to host time out with this form:

ssh -g -C -N -L 3307:127.0.0.1:3306 mysql-server 2200

It gives (another) host key verification error with this form:

ssh -g -C -N -L 3307:127.0.0.1:3306 mysql-server -p 2200

Placing the 2200 port in ~/.ssh/config under mysql-server makes no difference.

How do I get this to work?

4
  • 1
    I tried the format " ssh -p 2200 -g -v -C -N -L 3307:127.0.0.1:3306 mysql-server" and it worked for me - but so did "ssh -g -C -N -L 3307:127.0.0.1:3306 mysql-server -p 2200". I posit that if you are getting host key errors the issue is with the key being used rather then the tunnel syntax.
    – davidgo
    Commented Jun 26, 2021 at 4:07
  • 1
    -p 2200 is the right syntax. Host key verification error means some SSH server responded. What is the exact error message? Does it mention known_hosts? Doesn't it tell you what to do? Commented Jun 26, 2021 at 4:54
  • @davidgo Yes - that seems to be the case as I just tried it with the default port and still got the host key error.
    – GAM
    Commented Jun 26, 2021 at 7:15
  • @KamilMaciorowski no error(s) beyond those mentioned.
    – GAM
    Commented Jun 26, 2021 at 7:15

1 Answer 1

0

Ok - this came down to a private key with incorrect permissions. I didn’t detect this initially as I was using an application to create a job for the ssh tunnel. When I went on the command line, ssh complained and the problem became obvious. After correcting the permission on the key file, it then worked for the default port and after, it worked for the non-default port. Thanks to all for your help.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .