1

I have a mysql running in a machine(C) behind an SSH proxy machine (B). I want to connect to mysql on C on port 3306 using mysql workbench in my local computer(A). Machine B is accessible by machine A via ssh for a user abc with a private key. machine C is accessible to machine B via ssh for user root using the same private key (The key has to be forwarded which usually happens when I do A- ssh -> B - ssh -> C)

What should be my tunneling strategy? Do I need to use socks proxy?

Thanks

2
  • So you want to go from A to C via ssh is that correct? Commented Aug 4, 2016 at 14:43
  • Yes. I want to reach C from A Commented Aug 5, 2016 at 13:15

1 Answer 1

1

Although not an exact match, here are a couple of other closely related questions:

  1. how to access an ssh server that cant accept incoming connections
  2. establishing an ssh connection between machines behind firewalls

To solve your specific problem, I would add the following to your .ssh/config file on "A":

Host B
  User abc
  ForwardAgent yes

Host C
  User root
  LocalForward 3306:localhost:3306
  ProxyCommand ssh -A B -p 22 -W %h:%p
  #ProxyCommand ssh -A B -p 22 nc %h %p

With that in place, you should be able to use ssh C to:

  • get a shell on C, hopping through B, and
  • establish a local (to host A) port forward for your mysql workbench.

Once the connection is established, you can point your local (on A) mysql workbench at localhost:3306. If you have some other mysql instance running locally on A, choose a different port in the LocalForward configuration option and connect to that.

Note that there are two options for the ProxyCommand to jump through B to get to C. The alternative uses nc instead of the -W option to ssh, since the -W option wasn't addded unitl ssh version 5.3 (IIRC).

You don't need to use a SOCKS proxy.

You must log in to answer this question.

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