1

I have a script that runs some automatic zip generation using shell zip. The request is to add automatic encryption with password. From what I understand, the option -e is the right one, but it asks for the password by prompt; instead I need to make this step automatically, giving the password as an option or as a file.

In other words, if I write:

zip -e

Then a prompt asking the password two times is presented. Instead I want to do something like:

zip -e:thisisapassword

and have a zip file protected with password: thisisapassword

Does anyone any hints how to accomplish this?

Gareth
  • 19,080
Terix
  • 353

2 Answers2

1

Most forms of zip encryption do not support encryption with a command line password. Here is one form based on Igor Pavlov's 7-zip called jZip that might work -- have not tried it myself.

Option: -s[password]

nik
  • 57,042
0

Actually (if your are concerned with security) I would vote against automatic encryption with a fixed password in some script; instead I would encrypt to a public key that requires no password to encrypt, but only to decrypt. GnuPG can do such a thing (see Option --encrypt).

However you'll have to generate a PGP/GPG key pair first (the public key goes to public (i.e.: where your script runs), while the private ("secret") key should go where you decrypt the files).

There are a plenty of manuals, guides, and HOWTOs available, explaing the details.

U. Windl
  • 943