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.
Command to Encrypt
gpg --symmetric --cipher-algo aes256 -o abc-src.tar.gz.gpg abc-src.tar.gz
Enter passphrase: *******
Command to decrypt
gpg -d -o abc-src.tar.gz abc-src.tar.gz.gpg
gpg: AES256 encrypted data
Enter passphrase: *******
Usecase: We have a file on linux server, which needs to be encrypted and delivered to another machine.
Solution 1:- Encrypt a file
- 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
gpg -c TEST (It will ask for the passphrase/password, give a strong one and remember it)
It creates a file named TEST.gpg, which is encrypted. You can take a look at the content of this file
- Using gpg command for decryption
gpg -o TEST-d TEST.gpg
Where -o option tells to create a file TEST, instead of printing output on console
Strengthening encryption using AES256 cipher algorithm
Solution 2:- Encrypt the Source code or a folder
- cd TO_YOUR_FILE_LOCATION (I need to encrypt a file named TEST)
- tar -zcf abc.tgz abc
- Follow the command to encrypt
Command to Encrypt
gpg --symmetric --cipher-algo aes256 -o abc-src.tar.gz.gpg abc-src.tar.gz
Enter passphrase: *******
Repeat passphrase: *******
Command to decrypt
gpg -d -o abc-src.tar.gz abc-src.tar.gz.gpg
gpg: AES256 encrypted data
Enter passphrase: *******
No comments:
Post a Comment