Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use tar to compress file tar.gz with password [closed]

I use tar -czf test.tar.gz test/ to compress test forlder to test.tar.gz . Now, I want compress to test.tar.gz with password "mypass" How can I do?

like image 974
abent Avatar asked Jul 14 '14 10:07

abent


1 Answers

Neither the tar format nor the gz format has built-in support for password-protecting files.
Use crypt or gpg on the
Refer this encrypt-and-decrypt-files-with-a-password for more info.

tar cvvjf - /path/to/files | ccrypt > backup.tar.bz2.cpt

or

ccrypt backup.tar.bz2

And then to decrypt:

cat ../backup.tar.bz2 | ccrypt -d | tar -xjf -

You can also use zip

zip -e file.zip file

Will ask you on a prompt for a password. It is more secure then passing the password via the command line via zip -P password.

like image 136
Santosh A Avatar answered Oct 07 '22 20:10

Santosh A