Tuesday, January 3, 2012

Encrypting using GPG - an example

GPG stands for Gnu Privacy Guard, is a tool used to sign and encrypt data. Here I'm giving a simple usage of this tool.
Usecase: We have a file on linux server, which needs to be encrypted and delivered to another machine.

Solution:
  • By default every linux server comes with "gpg" tool. You can verify by running the command "which gpg"
  • Use gpg command to encrypt your file
           cd TO_YOUR_FILE_LOCATION   (I need to encrypt a file named CONARY)
           
           gpg -c CONARY           (It will ask for the passphrase/password, give a strong one and remember it)
           It creates a file named CONARY.gpg, which is encrypted. You can take a look at the content of this file
  • Using gpg command for decryption
          Now I have transferred this encrypted file (CONARY.gpg) to another server where gpg utility is available and run below command to decrypt it
         gpg -o CONARY -d CONARY.gpg
      
          Where -o option tells to create a file CONARY, instead of printing output on console


Strengthening encryption using AES256 cipher algo


Command to Encrypt
gpg --symmetric --cipher-algo aes256 -o dpm-3.2-src.tar.gz.gpg dpm-3.2-src.tar.gz
Enter passphrase: *******
Repeat passphrase: *******

Command to decrypt
gpg -d -o dpm-3.2-src.tar.gz  dpm-3.2-src.tar.gz.gpg


gpg: AES256 encrypted data
Enter passphrase: *******







         
                 


         
           

1 comment:

Shreeze said...

This blog is nice and very informative. I like this blog. blogPlease keep it up.