I want to share some of my source files for my new game with a colleague, but don’t want to send them in the clear. Is there a way to create an encrypted, password protected Zip Archive in Linux so I can email them safely? I’m running Ubuntu Linux, if that matters, and she’s working on a Mac.
While many operating systems have the ability to create encrypted files or folders and some email systems support secure file sharing, there’s a lot to recommend the Zip archive system, even if it’s over a hundred years old in Internet time. Actually, it was designed by Phil Katz of PKWARE and Gary Conway of Infinity Design Concepts and introduced back in 1989, if you’re curious!
At this point, every major operating system include a ZIP archive and unarchive or extraction application, though most are fairly crude or awkwardly designed as many basic utilities end up being. This means, however, that you can create a ZIP archive – including one with password protection – on any of the major operating systems and share it with users on any other OS. Mac to Windows? Linux to Mac? All of that works just fine.
The basic approach is straightforward too: Create a folder, copy all the files you want to send into that folder, then launch the ZIP utility to create an archived version of that folder and its contents, all neatly packed into that encrypted, password protected file. On Linux, the fastest and easiest is probably to just use the command line, so here’s how that would progress. First, check where you are in the file system with pwd then create the folder you want to send:
In this case I’m making a directory called SecretFiles.
Now’s the fun part; use the cp command to copy all the files you want into that folder. The ls command can show you the contents of the directory when you’re ready to proceed:
You can see I have a spreadsheet (financials.xls), a Word doc (readme.doc) and a plain text file FYEO (which stands for ‘for your eyes only’ if you’re stymied on that acronym).
On just about every Linux and Unix system on the planet, the ZIP command is known by the name zip, and the basic syntax is zip [flags] [outputfile] [list of input files and directories]. In this instance, you want to specify two flags -r and -e, the former denoting that it should recursively scan for files to include to ensure it includes the contents of the new folder, and the latter indicating that you want to encrypt the archive. Like this:
Notice it prompted for a password twice, to ensure you typed it correctly, then quickly added both the directory and the three files within, trying to compress (deflate) each of them. A win:win, really: it saves the files encrypted, and it shrinks them down to make them faster and easier to share too.
I specified “secret” as the output (second parameter on the command invocation) but it automatically added the correct suffix “.zip”. But there’s a really important limitation in these encrypted files that you should know about: the folder names and file names are not encrypted or hidden in any way. Consider when I enter the wrong password after trying to unzip the new archive:
For some people, that’s a show-stopper because the names of directories and files can contain a lot of information too, particularly if you have good naming practices. Above, even without the password, you can glean that I’m sending financials and a Word doc, more information than you probably want known. For most people, however, it’s not a big deal, just something to know about.
The file icon in Linux is identical if the ZIP archive is encrypted or not, as you can see:
Some operating systems differentiate so you can immediately recognize it’s encrypted, probably a better approach. If you are using the graphical user interface for your Ubuntu Linux system, then you can double click on the ZIP archive and explore the file hierarchy, which is disconcerting. Once you go to open up a file of any sort, however, it prompts:
Let’s look at sharing it with your colleague, however. One easy way to share it is through Gmail as an attachment. This is where that compression (deflation) is helpful. You might need to warn her, however, that when she receives the email it might be a bit alarming in Gmail:
That’s ok if she can verify with you that you did indeed send it and it’s not a scam or malware. Then she can save the attachment to her own Downloads folder and double click on it:
That’s it. Once she correctly enters the archive password it all be unpacked and extracted and a new folder will exist on the Mac system with all the original contents you included:
Windows is mostly the same, though creating a password protected ZIP archive on a Win system is a bit more convoluted. I explain how to do that here: How to Create a Password Protected Encrypted Zip Archive on a Windows 10 System. You can also read my Create An Encrypted Zip Archive on your Mac Easy article too!
Pro Tip: I’ve been writing about Linux since the dawn of the operating system. Please check out my extensive Linux and Unix help area for lots more tutorials while you’re visiting!