Connecting to remote server using a jump server (SSH tunneling)

Problem statement

There are 3 hosts,
Host-user – one that you are on
Host-jump – one that has connectivity to database server
Host-database – database server

Host-user wants to connect to Host-database using Host-jump.

Solution

Setup ssh tunnel with local port forwarding that allows you to forward a port on the local (ssh client/ Host-user) machine to a port on the remote (ssh server/Host-jump) machine, which is then forwarded to a port on the destination machine (Host-database).

$ ssh -C2qTnNf -L 1035:hostname-database:1025 user@hostname-jump

C – Compress all data, because web traffic is mostly text.
2 – Force SSH to try protocol version 2 only.
q – Quiet mode.
T – Disable pseudo-tty allocation, since we are just forwarding a port.
n – Prevent reading of STDIN, since we are just forwarding a port.
N – Do not execute a remote command, since we are just forwarding a port.
f – Run in the background.

 

Next?

On Host-user we connect to Host-user:1035, this establishes connection to Host-database:1025 using server Host-jump.

 

HTH

 

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *