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.gzfile.tar -czf - <filename>.gz: This command combines the compressed file with tar and creates a.tar.gzfile.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 the command line to tar and zip a file?
- How do I use gzip and tar in Linux?
- How do I use the command line to create a tar file?
- How do I compress a file using gzip and tar.xz?
- How do I use the Unix tar xvf command to extract files?
- How do I use tar gzip with a password?
- How do I use the command line to tar and zip files?
- How do I use tar commands with xz?
- How do I use gzip with tar?
- How do I use the tar command line in Windows 10?
See more codes...