Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Creating a SSH tunnel passing through a 'bridge' machine

Tags:

ssh

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?

like image 704
mariosangiorgio Avatar asked Aug 08 '12 09:08

mariosangiorgio


People also ask

What are the 3 types of SSH tunneling?

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.

Is SSH tunneling the same as 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.


Video Answer


1 Answers

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 
like image 70
mariosangiorgio Avatar answered Nov 07 '22 00:11

mariosangiorgio