Reputation: 671
From my local machine, I have SSH access to server A. Once on Server A, I connect to mysql on server B via port 3306 on server B.
mysql -h <B.hostname> -P 3306 -u <username> -p
I do NOT have ssh access to server B, either from my local machine or from server A.
What I'd like to do is have access to mysql on server B from my local machine. Every tunneling/port-forwarding link I've found assumes that I can ssh into server B.
Upvotes: 2
Views: 4056
Reputation: 455
ssh's -L takes a local port, a remote hostname to connect from the ssh server you connect to, and the remote port. In this case, you'll run:
ssh -L 3307:B.hostname:3306 A.hostname
This will make ssh connect to A, and when you later connect to port 3307 using a local mysql client (mysql -H localhost -P 3307 -u ...
), A's sshd will initiate a connection to B.hostname:3306 for you.
Upvotes: 3
Reputation: 727
Sounds like you have to use remote port forwarding. Try this on your local host:
[auto]ssh -R 1111:127.0.0.1:2222 -f -N -4Cp1234 [email protected]
So you get on your localhost:2222
(local machine) everything you get on localhost:1111
(when you logged in on servername.net), with traffic going by SSH on servername.net:1234
.
If your "server A" could access "server B" somehow, and you could access "server A" via SSH, that could probably help you.
Upvotes: 0