Tuesday, June 11, 2013

Password Protection of Zip files

Pass the option –P to the zip command to assign a password to the zip file.

zip -P mysecurepwd var-log-protected.zip /var/log/*
The above option is good if you are using the command inside a shell-script for background jobs. However, when you are performing the compression interactively on the command-line, you don’t want the password to be visible in the history. So, use the option –e as shown below to assign the password.

# zip -e var-log-protected.zip /var/log/*
Enter password:
Verify password:
updating: var/log/acpid (deflated 81%)
updating: var/log/anaconda.log (deflated 79%)

When you are uncompressing a password protected file, it will ask for the password as shown below.

# unzip var-log-protected.zip
Archive: var-log-protected.zip
[var-log-protected.zip] var/log/acpid password:

No comments:

Post a Comment