1

I am attempting to daisy chain tunnels/ports to access mysql on a secured server. Without opening up iptables, I would like to, from my local machine:

mysql -uadmin_user -p -hlocalhost:8002 

and have it jump ssh tunnel connections through to the servers ultimately to remote2.private-ip:3306 as described in my set-up screenshot.

My set up is like this: Server-Setup

I had been trying this for a while, and I gave up with the 3 way hop for now and I have been attempting to get it working with 1 and remote 2 connected first. I still can't get that to work yet either. Then I went to remote2 and I can't get the tunnel to work on remote2-private either.

Initially I used

remote2: ssh -f -N -M -S ~/.ssh/sockets/remote2-private-tunnel.sock -t -A -R 8002:localhost:3306 user@remote2.private-ip

And then I tried:

remote2:ssh -f -N -R 8002:remote2.private-ip:3306 remote2.public-ip

And with both of those, I cannot from remote2:

remote2: mysql -uadmin_user -p -hremote2.public-ip:8002

I can tell it is not getting to the mysql server because I get the error

ERROR 2005 (HY000): Unknown MySQL server host 'remote2.public-ip:8002' (0)

instead of something similar like:

ERROR 1045 (28000): Access denied for user 'admin_user'@'remote2.private-ip' (using password: YES)

I feel like I am just overwhelmed here and am missing something simple that I should be seeing. Any help would be much appreciated.

I should note, SSH keys are being used, and connectivity is established ssh'ing to them normally. Also, normal mysql connection to remote2.private-ip is also working. Also remote1 and remote2 are both joined on private networking and mysql from remote1.private-ip CLI to host remote2.private-ip works as well.

  • Look up SSH jump hosts. Using that you can do ssh remote2 directly from your local machine. Then you only need to forward ports once. – muru Jul 8 at 16:20
  • I think jumphosts are definitely the way to go, and look so much simpler than these multi-hop tunnels. I will update with my jumphost config to help others once I get it ironed out. – Joseph Michael Jul 12 at 15:50
  • If you're having problems with the jumphost config, maybe update your question or post a new question, I (and others here, of course) can help. I just didn't want to touch the multiple port-forward thing going on here. – muru Jul 12 at 16:41

Your Answer

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

Browse other questions tagged or ask your own question.