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 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.

share|improve this question

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

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

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
add comment

1 Answer 1

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.

share|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 –  user103382 Dec 7 '11 at 9:23
    
No intervention is needed. The config is in your ~/.ssh –  Sirex Dec 7 '11 at 10:44
add comment

Your Answer

 
discard

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

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