Total Pageviews

Wednesday, October 27, 2010

Encrypting & Decryption of Folders in Linux

Encrypting

1) Lets take the folder named RHN and compress it usning tar

tar -czvf RHN.tar.gz RHN/

2) ls -l RHN.tar.gz
-rw-rw-r-- 1 pradeep pradeep 10368 2009-08-27 12:33 RHN.tar.gz

3) Encrypt the file using the below command

gpg -c RHN.tar.gz

Enter passphrase:feedyourpassword
Repeat passphrase: refeed the same password


So it will create a new file called RHN.tar.gz.gpg

ls -l RHN.tar.gz.gpg
-rw-rw-r-- 1 pradeep pradeep 10423 2009-08-27 12:35 RHN.tar.gz.gpg

Decryption

You can decrypt the file from the command line  like below


[pradeep@pradeep oops]$ gpg RHN.tar.gz.gpg
gpg: CAST5 encrypted data
Enter passphrase:
gpg: encrypted with 1 passphrase
gpg: WARNING: message was not integrity protected


[pradeep@pradeep oops]$ ls
RHN.tar.gz  RHN.tar.gz.gpg

No comments: