cli-tarHow do I use tar and gzip to password protect a file?
Using tar and gzip to password protect a file is a two-step process. First, the file needs to be compressed and then encrypted.
- Compress the file with gzip:
gzip -c <filename> > <filename>.gz
- Encrypt the compressed file with tar:
tar -czf - <filename>.gz | openssl des3 -salt -k <password> > <filename>.tar.gz
gzip -c <filename> > <filename>.gz
: This command compresses the file with gzip and creates a.gz
file.tar -czf - <filename>.gz
: This command combines the compressed file with tar and creates a.tar.gz
file.openssl des3 -salt -k <password>
: This command encrypts the file with a password.
The resulting file will be <filename>.tar.gz
and it will be password protected.
Helpful links
More of Cli Tar
- How do I use gzip, tar, and zip to compress files?
- How do I use the shell to tar and zip files?
- How do I use the Unix tar zip command?
- How do I create a tar.zip file in Unix?
- How do I use the command line to tar and distribute files?
- How do I use the command line to tar and zip files?
- How do I use the Unix tar xvf command to extract files?
- How do I use the command line to tar and zip a file?
- How do I use the command line to tar and zip a file?
- How do I extract files from a tar archive using the cmd command?
See more codes...