Subject: port forwarding through a machine

port forwarding through a machine

From: Bradley Hittle <>
Date: Thu, 26 Aug 2010 11:31:13 -0400


Sorry if this is a repost, I thought I was added to the list but added and resending.

I've been using the libssh2 library in my application to communicate with a remote server from a thin client application. So far, I have to say I am very happy with libssh2 =).

The application I wrote will send commands to the server (transfer files, run scripts, etc), and it will port forward my local port to the server. My question is about forwarding through an intermediate machine, so in my case the machines I want to access are on a private network. If its just the server (send a local port to the server) then this case is working. I want to extend this to involve a second hop. The plink equivalent (-L option) lets you specify the local host/port, then the remote host/port to use to tunnel through.

A:12345-> A:22 -> B:22 -> B:12345 (thin client A connects to B)
A:12345-> A:22 -> B:22 -> C:22 -> C:12345 (thin client A forwards through B to C)

Now my question involves what I should be using to connect to the remote machine. I want to connect to the Server B initially, but how do I tell B to send its contents to machine C? Would I want to have an application that sits on B that sends its contents to C?

A:12345-> A:22 -> B:22 -> B:12345 -> B:12345 -> B:22 -> C:22 -> C:12345

Many thanks for the help!

Received on 2010-08-26