Take the 2-minute tour ×
Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free, no registration required.

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

share|improve this question
add comment

3 Answers

up vote 28 down vote accepted

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).

share|improve this answer
1  
Actually I want to try using it to speed up running X applications over SSH. My server has plenty of free CPU and RAM resources and client is not too weak too. –  Ivan Nov 5 '10 at 21:10
    
Compression in sshd_config can be either "yes" or "delayed". "delayed" is more secure, since a zlib vulnerability doesn't expose you, so it's the default, but some old clients like Tunnelier only support "yes". openssh.com/txt/release-4.2 –  endolith Aug 24 '12 at 20:57
    
Compression can either be yes or no the man page says... Thanks anyway, needed to uncompress it for my Android phone... –  Wilf Dec 22 '13 at 17:04
add comment

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.

share|improve this answer
add comment

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
share|improve this answer
add comment

Your Answer

 
discard

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.