I have a MySQL server sitting behind a bastion server that I wish to connect to from my local machine.

Ideally I want to port-forward the MySQL port (3316 in this case) to a local port on my machine.

I've tried plink -ssh -L 3306:my.sql.ip.address:3316 my.bastion.server ,but this is not working.

I've got one ssh login for the bastion server and another login for the machine mysql server is running on.

link|improve this question
1  
This seems like a serverfault.com question. – Marcus Adams Apr 7 '10 at 13:25
Agreed, serverfault.com can help you more with networking and firewall type questions. – JYelton Apr 7 '10 at 14:50
I'd say that it's a ssh usage question, and goes to Super User. – dmckee Apr 7 '10 at 16:49
1  
> I've tried plink -ssh -L 3306:my.sql.ip.address:3316 my.bastion.server ,but this is not working. Can you elaborate on what is not working? What error messages do you receive? – Jed Daniels Apr 7 '10 at 19:20
feedback

migrated from stackoverflow.com Apr 7 '10 at 16:49

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

1 Answer

You can double-chain SSH port forwards, bit a slightly easier method is to set up a "proxy" config in .ssh/config:

Host *%proxy
    ProxyCommand ssh proxy-user@proxy.host "nc -w1 $(echo %h | cut -d%% -f1) 22"
    ForwardAgent yes
    StrictHostKeyChecking no

Then use ssh -L 3306:127.0.0.1:3316 final-user@final.host%proxy to bring up the seesion.

I use this all the time, although normally with dyanamic port forwards (-D 1080) to get to management modules of hosts behind overly restrictive firewalls.

link|improve this answer
is it possible to achieve this without any possible intervention on the bastion server? i.e. admin will not configure the proxy on the bastion. Thanks – Mat Dec 7 '11 at 9:23
No intervention is needed. The config is in your ~/.ssh – Sirex Dec 7 '11 at 10:44
feedback

Your Answer

 
or
required, but never shown

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