How can I use password protection with the tar
command in Linux? I'm new to Linux so please explain to me with simple usage.
4 Answers
As far as I know tar doesn't provide this service. You could use 7zip instead, which does offer encrypted archives.
What you can also do is use gpg
in addition to tar:
tar cvJf myarchive.tar.xz myfiles
gpg -c myarchive.tar.xz.gpg
This will give you a password protected archive.
-
hi thanks a lot, can you elaborate a little bit about this command tar cvJf myarchive.tar.xz myfiles gpg -c myarchive.tar.xz.gpg Sorry I'm new to Linux.– kevinApr 19, 2011 at 8:38
-
1You need to read a tutorial on the linux command line. This is basic stuff.– PeltierApr 19, 2011 at 8:47
-
Thanks again !!! Can you point me some good tutorial ?– kevinApr 19, 2011 at 8:59
-
1In addition, look at the links of this page: reddit.com/r/Ubuntu/comments/bbnkp/…– PeltierApr 19, 2011 at 9:12
-
Run the output through pgp
tar .... | pgp --symmetric output.tar.pgp
decrypt:
pgp -d output.tar.gz | tar tv
Consider using proper asymmetric keys (public/private keys) for real protection
-
@sehe - Thanks a lot. But unluckily, I don't understand what you had written. Can you tell me a bit more detail? Thanks !!!– kevinApr 19, 2011 at 8:40
-
1@kevin: To my understanding, a "symmetric key" is a plain-old password-based system, like you're familiar with. An asymmetric key system has two "passwords" or keys, a public and a private one. You can share the public one freely, and people use this to identify you. The private key is the part that proves that you are you, so sharing it is a Bad Thing. Anyhow, the symmetric key is almost certainly what you want, since it's much simpler, although the asymmetric key is more secure, in theory.– bukzorApr 19, 2012 at 15:44
Simple way
Step 1 : sudo apt-get install zip
Step 2 : zip -P password file.zip files
-
3
To zip a file with password run the following command:
zip -er name.zip folder/
It will show a prompt to enter a hidden password.
To unzip the file, run:
unzip name.zip
And enter the password you added before.