Super User is a question and answer site for computer enthusiasts and power users. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 ?

share|improve this question
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.

share|improve this answer

You must log in to answer this question.

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