Speed up your ssh connections with compression

By default compression is not enabled for outgoing ssh connections on OS-X.

Very simple compression is no problem for modern CPUs and even on a gigabit network it is faster to compress data first before sending it over the network instead of leaving it uncompressed. However compressing data that can’t be compressed anymore (like JPEG files) makes no sense. If your typical ssh traffic is not .jpeg or .zip files then read on.

First check if your ssh traffic is compressed by starting a ssh session with the -v switch.

You should spot two lines:

debug1: kex: server->client aes128-ctr hmac-md5 none
debug1: kex: client->server aes128-ctr hmac-md5 none

Notice the none at the end of each line.

Compression can be enabled by default for all ssh sessions. Just put a file (or modify it if it’s already there) called config into your ~/.ssh/ directory and add the following two lines:

Compression yes
CompressionLevel 6

Another ssh session with -v should give you the following:

debug1: kex: server->client aes128-ctr hmac-md5 zlib@openssh.com
debug1: kex: client->server aes128-ctr hmac-md5 zlib@openssh.com

How much faster is it?

I used cat some-50mb-long.log to output the content of some 50mb log file directly to my ssh session and noticed a 3-4x speed increase on compressed data of a normal web server log file.

As you are probably not displaying 50mb files in your ssh session on a daily basis you might notice a slightly more responsive remote and less load on you network.