Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 Apr 7 '10 at 16:49

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

> 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

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 "nc -w1 $(echo %h | cut -d%% -f1) 22"
    ForwardAgent yes
    StrictHostKeyChecking no

Then use ssh -L 3306: 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

Your Answer


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.