Zip is an useful and frequently used tool for compressing files/directories on Linux as well as on Windows.

In this post, we will let you know how to use zip command with password protection.

Install zip package on server using yum or rpm

# yum install zip    [On CentOS/RHEL] 
# sudo apt-get install zip [On Debian/Ubuntu]

After installation, you can use zip command with -P flag to create a password protected zip file.

# zip -P [email protected] mydir/

adding: mydir/ (stored 0%)

But in this way the password is still be visible in Bash History. That is why, it is insecure.
So use flag -e to encrypt the zip file

# zip -e mydir/ 

This command will prompt you for password, and allow you to enter hidden password:

Enter password:
Verify password:
adding: mydir/ (stored 0%)

%d bloggers like this: