Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to get to a mysql server on a remote network, and to get to it I currently have to do several ssh hops, so I can use the mysql command line interface. I'd really like to do a mulit-hop tunnel so I can just use a gui from my desktop. How would this work?

Here's the order:

MacDesktop --> DevServer -->StageServer --> Mysql01

All (except the mac desktop)are linux boxes, and mysql is running on the standard port. Any Hints? Or an exact connection string?

share|improve this question
    
Hrm. Seems like that didn't work. Not sure what I'm doing wrong, but I'm essentially putting: (in Terminal one) dev.xyz.com>: ssh -L 3306:user@Mysql01.xyz.com:3306 @userStage.xyz.com (in Terminal two (on my mac)) ssh -L 3306:127.0.0.1:3306 user@dev.xyz.com It looks like the dev server is running mysql on it.. so am I going to need to forward a different port? If so, how? edit: I'tried port 3307, but when I did a netstat -an | grep 3307 on any of the hosts, it never showed up. :-/ –  user95344 Sep 20 '11 at 19:03
add comment

migrated from stackoverflow.com Sep 20 '11 at 7:16

This question came from our site for professional and enthusiast programmers.

1 Answer

You can use ssh to forward the ports(assuming that the mysql server is configured to accept connections from StageServer on port 3306):

# Forward port 3306 from Mysql01 to local port 3306 on DevServer using StageServer in the middle
DevServer > ssh -L 3306:Mysql01:3306 StageServer
# Forward the local port 3306 on DevServer to local port 3306 on your Mac
MacDesktop> ssh -L 3306:127.0.0.1:3306 DevServer

Now configure the gui client to connect to 127.0.0.1:3306 (Make sure you're not running mysql on your Mac or forwarding to port 3306 will fail, or use another port for forwarding)

Edit: Make sure that local port forwarding is enabled in ssh server configuration.

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.