Linux – How to password protect a .tgz file with tar in Unix

archivinglinuxpassword-protectiontarunix

I'm using the Unix tar command as follows to tar up a directory and its files:

tar cvzf fileToTar.tgz directoryToTar

Is there a way to password protect the .tgz file? I've created password-protected ZIP files on Windows so I would assume Unix has the same capability. Any ideas?

Best Answer

Use crypt or gpg on the file.

Simple examples:

cat filename | crypt > filename.crypt

gpg -c –o filename.gpg filename

Related Question