I want max compression on my ssh tunnel cos I'm on a dialup line ;)

At the man page can one can read:

CompressionLevel .....The meaning of the values is the same as in gzip(1). Note that this option applies to protocol version 1 only.

What if I want max compression rate and while using ssh version 2?

How know the protocol version I'm using?


To know the protocol version of ssh, you can include -v option in your ssh command.

To request compression, you can use -C option. This should work even for protocol version 2.

| improve this answer | |
  • 1
    But what about CompressionLevel option? I don't want use the default level, 6, but the 9 cos I'm over a diulup connection. – user120858 May 13 '12 at 14:54
  • 1
    @frankabel: As I understood from the manual, you can only set the compression level for protocol version 1, but I am not sure about this. – Khaled May 13 '12 at 14:56
  • 1
    Bad news, here lists.mindrot.org/pipermail/openssh-unix-dev/2003-November/… I found that ssh2 is less capable than ssh1 regards compression configuration. – user120858 May 13 '12 at 15:17
  • 1
    Seem to me that if want use max compression level (9), I must use ssh 1 instead of ssh 2 – user120858 May 13 '12 at 15:22
  • 9
    Just leave it at the default and use ssh2. The difference isn't much, and the security gain from using v2 is worth it. – Bill Weiss May 13 '12 at 15:26

Depending on your use case, you might want to utilize pipes in order to achieve higher compression levels for certain streams.

ssh ${SSH_USER}@${SSH_HOST} "
    echo 'string to be compressed' | gzip -9
" | zcat | echo -

The above example compresses the string/stream on the remote side (gzip) and decompresses it upon receipt on the local side (zcat).

Note that ssh's compression is off on intention. Only the pipe's compression is used.

You may use other compression tools like bz2 or xz as well. Consider their respective performance impacts.

NOTE: It seems that, if the compression uses a very slow algorithm, the stream can fail to deliver in time and the connection "closes" with an error.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy