2

I want to set up my ssh tunnel to do dynamic compression so that I get maximum throughput for the bandwidth and CPU resources I have available on each end. Since gzip compression is built-in and not pluggable I thought I could use -o ProxyCommand to set up a double ssh tunnel where the outer tunnel sends compressed data as the content and the inner tunnel connects to the ssh daemon on the remote host. This almost works. Here is my command:

# dynamic compression parameters to zstd omitted for brevity
ssh -o ProxyCommand='zstd | ssh -p %p %h "unzstd | nc localhost %p | zstd" | unzstd' <hostname>

Here are some things I know about this command:

  • When I run this command the terminal hangs without any output.
  • It works if I remove [un]zstd, which is not surprising since using netcat as the proxy command is a standard method to connect through jumphosts
  • cat | zstd | cat at a command prompt will not return data immediately because compression programs process data in chunks. You have to send EOF with ctrl+d a couple times before it releases the compressed data. You can decompress the data within the pipeline as well and it works the same.
  • If I hit ctrl+d when running the full command nothing happens.

What am I missing here? Is there a way to make this work or another way I am overlooking?

ChinnoDog
  • 21
  • 1

0 Answers0