Last updated: April 17, 2019
How to Decompress ZIP Archives With SSH
Disclosure: Your support helps keep the site running! We earn a referral fee for some of the services we recommend on this page. Learn more
Moving large files between different networked computers can be a shockingly slow process. The situation is much worse if you are moving files from your home computer to a server. Imagine if you had a 6 Mb/s internet connection. A one gigabyte file would take about a half hour to transfer. And that’s not even taking into account the fact that upload speeds are usually quite a bit slower than download speeds. By using compression utilities, you can greatly reduce the time it takes to transfer files.
In general, the internet is not compressed. It certainly can be for specialized purposes, but the internet itself is too heterogeneous for that. What’s more, all network signals are broken up into small packets — generally not larger than 1,500 bytes. So the process itself can’t be compressed to nearly the extent that a single large file can be. Thus, to greatly reduce the time it takes to transfer a file between two computers, the file must be compressed at the start of the process, and then uncompressed at the end. And generally, this has to be done by hand.
It is possible to automatically have files compress and uncompressed on each side of a data transmission. But this requires having, for example, an ftp client and server that speak the same compression language. For example, Filezilla uses mode Z compression. So if a Filezilla client is transferring files to a Filezilla server, files can be automatically transmitted in compressed form without the user even being aware of it. Unfortunately, most hosting computers are not set up with compression-enabled ftp servers. But if you control your own server operating system, you may want to consider a solution like this.
Using Secure Shell and Zip
For most website owners, installing an ftp server that supports compression isn’t an option. And even when it is, transferring large files is not usually a common enough task to bother tinkering with the operating system. For these users, it is easier to just do it by hand. All you have to do is have a compression utility on your local machine and secure shell (ssh) access to your remote machine.
There are lots of compression tools, but zip has a number of advantages. The biggest one is that it is everywhere on every platform you can think of. Another is that zip doesn’t just compress files, it also archives them. If you are using a compression tool like gzip to manage a large number of files, you will need to archive them first with tar, and then compress them. So zip is easier: it does what you need and it is always available. On the other hand, zip generally does worse in terms of raw compression compared to gzip and rar. So if compression is critical to you, zip may not be the best choice.
Secure shell is a text-base terminal window that allows the user to operate a machine remotely over a secure connection. Most servers run a ssh daemon (sshd), which listens for ssh connections and allows users to log on. This requires that the user have a ssh client. On a Mac, ssh is already installed. Just open up a terminal and type “ssh UserName@HostName -pPortNumber.” And on unix machines, you use the same command. There are various Windows programs that you can use. One of the most popular is PuTTY, which is free and very easy to use.
Transferring and Decompressing Files
The process for transferring compressed files between computers is pretty simple. There are three parts: compress the file(s) on the original machine; ftp the files to the destination computer; uncompress and extract the transferred file on the destination computer. Here are the steps:
- Compress the file(s) into a zip file (eg, file.zip).
- Ftp the compressed file (eg, file.zip) to the destination computer.
- Open a ssh connection to the destination computer and log in.
- Find the uploaded file (eg, file.zip).
- Move the file to where you want to extract it (eg, mv file.zip destination).
- Use the unzip command to extract the files (eg, unzip file.zip).
It might take some time to compress and uncompress your files. But even on very slow machines, it will be nothing compared to the time that you save during transmission. If this is something that you need to do often, and if you have the opportunity, you might consider setting up a compressed ftp server. But the system presented here will always work and is easy to use.
Updated August 2015