Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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?

share|improve this question
up vote 1 down vote accepted

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.

share|improve this answer
But what about CompressionLevel option? I don't want use the default level, 6, but the 9 cos I'm over a diulup connection. – gsi-frank May 13 '12 at 14:54
@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
Bad news, here… I found that ssh2 is less capable than ssh1 regards compression configuration. – gsi-frank May 13 '12 at 15:17
Seem to me that if want use max compression level (9), I must use ssh 1 instead of ssh 2 – gsi-frank May 13 '12 at 15:22
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.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.