3

Can the encryption option on Info-ZIP be used from the command line? The zip man page says:

-e --encrypt Encrypt the contents of the zip archive using a password which is entered on the terminal in response to a prompt (this will not be echoed; if standard error is not a tty, zip will exit with an error). The password prompt is repeated to save the user from typing errors.

Is there a way to create zipped files from an unattended script?

Stuart Woodward
  • 1,343
  • 4
  • 14
  • 29
  • 1
    If you really want any level of encryption worth mentioning (zip encryption is trivial to crack) you should use something like `openssl bf -salt -k passphrase -in file.zip -out file.zip.bfe` to encrypt the zip file (this can also be done on the fly by piping. Decryption is as easy as `openssl bf -d -salt -k passphrase -in file.zip.bfe -out file.zip`. Zip doesn't support unzipping from a pipe, so you can't decrypt a zip on the fly with openssl. You can use gzip and tar however, it depends on your needs. – Chris S Mar 08 '12 at 03:02
  • @ChrisS I guess there is a free OpenSSL client for windows too. The zipped files will be sent to an FTP server to be picked up by a Windows user. The encryption is mainly just to avoid a casual user from accidentally peeking into the file. – Stuart Woodward Mar 08 '12 at 04:32
  • N.b. The zip command on Redhat is copyright Info-ZIP. – Stuart Woodward Mar 08 '12 at 04:47

1 Answers1

7

Using -P will allow you to pass the password on the command line.

Ignacio Vazquez-Abrams
  • 45,939
  • 6
  • 79
  • 84