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?
Transporting arbitrary data streams over SSH sessions is also known as SSH tunneling. OpenSSH, a popular open-source SSH server, supports three types of tunneling features- local port forwarding, remote port forwarding, and dynamic port forwarding.
SSH port forwarding is often referred to as SSH tunneling, and the two terms are used interchangeably. The encrypted SSH 'tunnel' serves as a vessel to transfer assorted data and deliver it safely to the remote system. This method is regularly used to circumvent standard firewall security protocols.
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With