Making output of data from remote hosts smaller

so i'm doing something similar to this:

ssh myname@remotehost 'tail -800 /var/log/some.log'

Now, as you can see, this is a lot of data to be passing back and forth over a network.

Is there anything i can do to make the output smaller (zip it on the fly, compress?) and then when the data gets back to my local box, i can unpackage it to its original?

im looking for a one liner type of thing.

Simple enough:

ssh -T myname@remotehost 'tail -800 /var/log/some.log | gzip' | gunzip

The -T prevents it from allocating a pseudo-terminal and doing any escape sequences, making the stream binary-safe.

1 Like

You can also do ssh -C but that's not always supported.

1 Like

ssh supports compression if you tell it to, using the -C flag
From man ssh :

     -C      Requests compression of all data (including stdin, stdout, stderr, and data for
             forwarded X11 and TCP connections).  The compression algorithm is the same used
             by gzip(1), and the �level� can be controlled by the CompressionLevel option
             for protocol version 1.  Compression is desirable on modem lines and other slow
             connections, but will only slow down things on fast networks.  The default
             value can be set on a host-by-host basis in the configuration files; see the
             Compression option.

Some ssh implementations support compression, OpenSSH for instance. Those that don't may just ignore it or throw errors. The remote host also has to support it.

1 Like