I am curious, does SSH compress its data before sending/receiving it? If it does not by default, then can it be turned on?
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).
man ssh_config for details. You're looking for the
CompressionLevel options, which you can then set in
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
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).
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 -C hostname
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.