How do I connect to MySQL database through two SSH hosts ?

Here is my situation: I have two SSH hosts as show below. MySQL is running in BOX2 host.

MyBox(GUI client) -----SSH(port 22)--->BOX1(IP: 190.xx.xx.xx)---SSH(port 22)--->BOX2(IP: 190.xx.xx.xx)[MySQL server]

My question is how do I connect if I have multiple SSH hosts to tunnel as shown above ?

  • 1
    Why can't you just SSH to Box2 directly? Or if your MySQL server was compiled with SSL support, you could just initiate an SSL connection to it directly without an SSH tunnel. – Lèse majesté Apr 5 '12 at 10:59

You can set a ProxyCommand to connect transparently from MyBox to BOX2 (using BOX1 under the hood), so you can setup a -L redirection directly from MyBox to BOX2. Please read: transparent multihop SSH to get more details.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.