Reputation: 5543
I need to access from a PHP script a database hosted on another machine which is accessible only via SSH using a bridge machine.
How can I setup a tunnel so that I can tunnel the connection from my machine to the database passing through the 'bridge' machine?
Upvotes: 31
Views: 44079
Reputation: 5543
It is actually quite simple. It is just a matter of a single command:
ssh -N -L localhost:3306:DATABASE_MACHINE:3306 BRIDGE_MACHINE_USER@BRIDGE_MACHINE
Upvotes: 55
Reputation: 897
You should use ssh -L option to do this
You can read this: http://www.revsys.com/writings/quicktips/ssh-tunnel.html
Upvotes: 2