How to mimic ssh por forwarding with compression

José García Juanino jjuanino at gmail.com
Thu Dec 3 15:51:35 UTC 2015


Hi FreeBSD comunity,

I have two hosts with no ssh client nor server installed, let say
host_client and host_server. In host_server is running a net service
in port number 1540, which transfers huge amount of data to
host_client. I know that such data is heavily compressible.

The aim is make some port fowarding with compression between the two
hosts by mean of netcat or some similar tool (socat, etc). With netcat
we can do port forwarding in a easy way (backpipe is created with
mkfifo):

1) On server_host, run:

nc -l -p 9999 < /var/tmp/backpipe | nc localhost 1540 > /var/tmp/backpipe

2) In client_host, run:

nc -l -p 9999 < /var/tmp/backpipe | nc server_host 9999 > /var/tmp/backpipe

With this approach, you can configure client to connect to
client_host:9999, and magically works fine: the client succesfully
connects to server_host:1540 and can talk properly.


client_host:9999 <------------> server_host:9999 < ------------ ->
server_host:1540



Well, the idea is to compress the net traffic in the first step,
between client_host:9999 and server_host:9999. The improvement would
be huge.

I have tried the following, with no succes:

1) On server_host, run:

nc -l 9999 < /var/tmp/backpipe  | nc localhost 1540 | gzip > /var/tmp/backpipe

2) In client_host, run:

nc -l 9999 < /var/tmp/backpipe | nc server_host 9999 | gzip -dc >
/var/tmp/backpipe


But when I configure my client to point to client_host:9999, nothing
happens, and I get a conect timeout, as both client and server cannot
talk properly. Obviously, the problem is with gzip.

Any comment or suggestion will be welcome, regards.


More information about the freebsd-questions mailing list