How to use password protection with the Linux tar command?

17

9

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.

kevin

Posted 2011-04-19T08:20:17.250

Reputation:

Answers

14

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.

Peltier

Posted 2011-04-19T08:20:17.250

Reputation: 4 834

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. – None – 2011-04-19T08:38:00.337

1You need to read a tutorial on the linux command line. This is basic stuff. – Peltier – 2011-04-19T08:47:33.567

Thanks again !!! Can you point me some good tutorial ? – None – 2011-04-19T08:59:55.327

Try this site: http://gd.tuwien.ac.at/linuxcommand.org/

– Peltier – 2011-04-19T09:11:45.550

In addition, look at the links of this page: http://www.reddit.com/r/Ubuntu/comments/bbnkp/ive_tinkered_in_ubuntu_before_but_its_the_primary/c0lzpwk

– Peltier – 2011-04-19T09:12:03.210

This is two answers. – bukzor – 2012-04-19T15:45:11.377

7

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

Posted 2011-04-19T08:20:17.250

Reputation: 1 796

@sehe - Thanks a lot. But unluckily, I don't understand what you had written. Can you tell me a bit more detail? Thanks !!! – None – 2011-04-19T08:40:01.677

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. – bukzor – 2012-04-19T15:44:39.040

2

Simple way

Step 1 : sudo apt-get install zip

Step 2 : zip -P password file.zip files

Abhishek Goel

Posted 2011-04-19T08:20:17.250

Reputation: 201