Glam Prestige Journal

Bright entertainment trends with youth appeal.

I am curious, does SSH compress its data before sending/receiving it? If it does not by default, then can it be turned on?

5 Answers

No and yes. Kind of. Which is to say, it supports compression (zlib or zlib-ish, as I recall), but a stock copy of OpenSSH does not have it enabled by default, though some distributions may enable it by default (I don't think Ubuntu does).

See man ssh_config for details. You're looking for the Compression and CompressionLevel options, which you can then set in /etc/ssh/ssh_config.

Note that there's also a Compression option for the server side in sshd_config which determines if compression is allowed (it is by default). Again, see man sshd_config for details.

You can also turn compression on on a per-session basis by using the command line option -C.

Note that compression can actually have a slightly negative performance impact if the connection between you and the server is fast (e.g. on the same LAN or just on really good internet connections) or one or both sides has a slow CPU (compression eats a fair bit of CPU time).

These days, for most people, I'd suggest using it only as needed. Typically for links of less than 5-10mbps and only when passing a lot of bulk data (transfers of not-already-compressed files, X11 or VNC forwarding, things like that).

5

You can turn on gzip compression on any SSH. Put Compression yes into your ~/.ssh/config, and it should work. Alternatively, try running ssh with the -C option.

1

From the ssh man page (type man ssh to see the whole thing):

 -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 pro- tocol 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.

So just change:

ssh hostname

to:

ssh -C hostname
1

Easiest why is to use the -o option, on the cli. It can be used with any config option as well eg

ssh -o "Compression no" -v <HOST>
# or
ssh -o "Compression yes" -v <HOST>

you can switch on the compression with -C but it won't work if the server is not allowed to spend kernel power for it by not allowing compression for this. For example, I did, because of this, change the Host location of some own data from Strato to a server of mine. I recognised it because of the usage of a slow 2Mbit download and 0,3Mbit upload connection and did check out the speed difference depending on the compression level as higher level isn't allways quicker as it sucks of your processor power or the server power.
but in my case it does a good job as it is shorten the needed time to a 6th of the time before.

1

Your Answer

Sign up or log in

Sign up using Google Sign up using Facebook Sign up using Email and Password

Post as a guest

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