Introduction

SSH port forwarding allows you to securely access a remote server through a jump server (bastion host) when your local machine does not have direct network access. By creating an SSH tunnel, requests sent to a local port are securely forwarded through the jump server to the destination server.

Prerequisites

  • SSH access to the jump server
  • A local machine with an SSH client installed
  • Network connectivity between the jump server and the destination server
  • The destination server IP address and service port

Implementation

Step 1

Open a terminal on your local machine.

Step 2

Run the following SSH port forwarding command:

ssh -L <SOURCEPORT>:<IPADDRESS>:<DESTINATIONPORT> userid@<JUMPBOXIPADDRESS>

Where:

  • SOURCEPORT – Local port number
  • IPADDRESS – Destination server IP address
  • DESTINATIONPORT – Destination server port number
  • JUMPBOXIPADDRESS – IP address of the jump server

Step 3

For example, to access a Remote Desktop (RDP) server through a jump server, run:

ssh -L 3389:IPADDRESS:3389 root@JUMPBOXIP

Step 4

Keep the SSH session active while using the tunnel.

Step 5

Access the remote service from your local machine using the loopback address.

Example:

127.0.0.1:3389

Conclusion

SSH port forwarding provides a secure method to access remote services through a jump server without exposing the destination server directly. This approach is useful for securely accessing services such as RDP, SSH, or web applications in restricted network environments.

Leave a Reply