SSH compression

Solution 1:

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.

Solution 2:

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.