← Back to home
SSH Tunnel Port Forwarding FoxyProxy Red

SSH Tunnel: Secure Access Through Multiple Hops

Feb 1, 2022

Creating a chained SSH tunnel through multiple hops to securely access an internal web server from an external network.

Topology

Kali (172.26.0.x) β†’ VPS1 (192.168.50.10) β†’ VPS2 (192.168.100.10) β†’ Apache Server

1. Install SSH and Apache

# Kali:
apt-get install openssh-server
# VPS1 and VPS2:
sudo apt-get install openssh-server openssh-client
# Server:
sudo apt install apache2

2. Build the Chained Tunnel (3 terminals)

Terminal 1 β€” Kali β†’ VPS1

ssh -L 5678:127.0.0.1:4321 user@192.168.50.10

Terminal 2 β€” VPS1 β†’ VPS2

ssh -L 4321:127.0.0.1:1234 user@192.168.100.10

Terminal 3 β€” VPS2 β†’ Server

ssh -D 1234 user@192.168.10.10   # Dynamic SOCKS proxy

3. Configure FoxyProxy on Kali

4. Access the Internal Server

# In the Kali browser with FoxyProxy ON:
http://127.0.0.1
# Displays the Apache page of the internal server