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 5


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

  • 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, 2010 at 21:10
  • 2
    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, 2012 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, 2013 at 17:04
  • @Ivan Have you tried NoMachine NX or freenx? That should be faster than just commpressing ssh.
    – gmatht
    Jun 1, 2017 at 9:49
  • 1
    Note that CompressionLevel was an option that was only available for SSH protocol 1 which is no longer enabled by default with current versions of OpenSSH.
    – ckujau
    Jan 12, 2018 at 23:11

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
    I've found this makes a huge difference for file transfers over sftp. Can go from 1 hr down to 6 mins for large plain text files.
    – MikeKulls
    Aug 12, 2020 at 2:45
  • Tip if you use rsync (not sure how it works with SFTP) should really try using something like --compress-choice=zstd --compress-level=3 --checksum-choice=xxh3 that will compress the file using zstd. Great in instances where it's something like a giant CSV or text file or bunch of config files etc.
    – Josh
    Oct 27, 2023 at 9:54

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


ssh -C hostname
  • 2
    You can enable this option in PuTTY if you're using windows: Connection -> SSH -> Protocol options -> Enable Compression.
    – Wug
    May 14, 2014 at 6:22

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.

  • I do check at moment allways at starting the network if the Settet compression is gaining speed by doing a quick transfer in both options and checking the time. The resulted answer is than automated setting up compression or not. Since that I don't have to check my connection all the time before transferring something as it is allways better adjusted. Sep 7, 2019 at 4:50

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .