How to use SFTP compression

File Transfer Protocol (FTP) has very few advantages over Secure File Transfer Protocol (SFTP). However, if you measure the transfer speed between an FTP client and an FTP server and compare that with the speed between an SFTP client and an SFTP server in exactly the same network conditions, the FTP transfer usually comes out faster.
Of course, due to its security deficiencies, it’s not advisable to use FTP in a production environment. That said, it can still be tempting to use FTP if you simply need faster file transfers. But what if I told you it’s possible to speed up your SFTP transfers? One way is by employing SFTP compression. Let’s talk about that.
What is SFTP compression?
SFTP compression refers to the functionality wherein the size of transmitted data is reduced as it’s sent over an SFTP connection. This enables an SFTP transfer to achieve higher transfer rates in slow or high-latency networks. SFTP derives this compression functionality from the underlying Secure Shell (SSH) protocol.
It’s possible to compress data before transmission and achieve more or less the same results. For instance, you can compress files into zip, GZip or Tar GZ format, and then transmit them over SFTP. In effect, you’ll still be sending compressed data, i.e., data with smaller sizes. That means you’ll still be able to achieve faster transfers because smaller files do complete transfers faster than larger files.
That being said, this method isn’t considered SFTP compression. Strictly speaking, SFTP compression refers to in-transit compression, wherein data is compressed as it is being transmitted between client and server, not before transmission. SFTP compression is usually achieved through compression algorithms like zlib, which are readily available in SSH implementations like OpenSSH.
When do you need to compress files?
Compression can speed up data transfers, albeit with varying degrees of effectiveness. Because it’s also a CPU-intensive process, you sometimes need to weigh the pros and cons of using it.
Generally speaking, you would want to apply compression when you’re moving large files over slow, high-latency networks. Compression won’t make much of a difference if you’re moving smaller files over fast, high-bandwidth networks. In fact, it might even make your transfer slightly slower due to the added CPU overhead.
Another use case for compression is to have transferred files occupy a smaller space on your target filesystem. You can use it as a workaround if your target system has limited storage space. It’s worth noting that this second compression use case can’t be achieved using SFTP compression algorithms like zlib, which can only compress files in transit. Those files are decompressed as soon as they reach their destination system.
So, if your purpose for compressing files is to save on storage, you’ll want to use compression solutions that convert files into zip, gzip, or tar.gz format. It won’t be SFTP compression, but it solves the problem through compression nevertheless.
Not all file types compress well, though. Some files only compress slightly compared to others. Here’s a table that identifies which file types are suitable or unsuitable for SFTP compression.
Type of file |
Suitable |
Somewhat suitable |
Unsuitable |
Text files (e.g., txt, xml, csv, log, json) |
✅ |
||
Office documents (e.g., doc, docx, xls, xlsx) |
✅ |
||
Database dumps and SQL files (e.g. sql) |
✅ |
||
Logs and configuration files (e.g., log, conf, ini, yaml) |
✅ |
||
Uncompressed media files (e.g., bmp, tiff, wav) |
✅ |
||
Already compressed files (e.g., zip, gz, tar.gz, jpg, png, mp3, mp4) |
✅ |
||
Binary and executable files (e.g., exe, bin) |
✅ |
In most cases, SFTP compression is not enabled by default. So, if you want to take advantage of this capability, you’ll want to know how to enable it. Let’s now discuss some of the ways to enable compression on different SFTP tools. Since many SFTP deployments use OpenSSH, let’s start with that.
How to enable SFTP compression using OpenSSH
OpenSSH is the most widely used implementation of SSH. You can find it installed by default on Linux, UNIX, macOS and even newer versions of Windows Server. OpenSSH offers compression through the zlib compression algorithm.
To enable zlib compression on the command line, you can use the -C option with the SSH, Secure Copy Protocol (SCP) and SFTP commands. So, for example, you can enable it for the SFTP protocol by issuing the following command prior to authentication:
sftp -C user@host
Here, “user” should be a valid username on the SSH server and ‘host’ should be the server’s IP address or hostname.
For compression to work, you have to configure the server to apply zlib compression. You can set that in the SSH configuration file (~/.ssh/config or /etc/ssh/ssh_config) like so:
Host *
Compression yes
In older versions of OpenSSH, you could set the compression level. However, that feature is no longer supported in more recent versions.
How to enable compression on GUI-based SFTP clients
Most end users prefer to use SFTP through graphical SFTP clients like WinSCP or JSCAPE AnyClient by Redwood. Here’s how you would enable compression on these clients:
Enabling SFTP compression on WinSCP
On the Login dialog, click the Advanced button.
Once the Advanced Site Settings appear, navigate to the SSH node and then tick the Enable compression check box.
Enabling SFTP compression on AnyClient
You can’t enable zlib compression on AnyClient. You can, however, zip a file before uploading it. As explained earlier, this achieves the same effect in that it reduces the size of your file, thereby resulting in a faster transfer.
To zip a file and then upload it to your SFTP server, connect to your server. Once connected, select the file you want to zip and then click the Zip Upload button.
How to enable SFTP compression using JSCAPE MFT Server
JSCAPE MFT Server by Redwood is a managed file transfer server that supports SFTP, along with several other file transfer protocols, including File Transfer Protocol-SSL (FTPS), Applicability Statement 2 (AS2), Web Distributed Authoring and Versioning (WebDAV), Odette File Transfer Protocol (OFTP) and many others.
JSCAPE MFT Server makes it easy to build automated workflows without writing a single line of code. It integrates with a wide range of applications and services through a massive selection of connectors and a robust API. JSCAPE MFT Server is also backed by an array of security features to help you protect your file transfers from cyber threats and achieve regulatory compliance.
If you want to try it out, you may request a free trial or schedule a quick demo with an MFT expert.
A JSCAPE MFT Server-delivered SFTP service already has SFTP compression enabled by default. But just in case it’s been disabled, you can enable it by following these steps.
Go to Domains > Listeners > SFTP/SCP tab > Algorithms.
The SFTP/SCP Algorithms dialog contains configuration settings for the various SFTP algorithms, including key exchanges, host/public keys, ciphers, message authentication codes (MACs) and compressions. Once the SFTP algorithms dialog appears, click the Compressions tab. Check if the zlib checkbox is ticked. If it is, then zlib compression is enabled.