Linux Encryption & Decryption

For us, administrators who work on thousands of data, we are in doubt of how our files are secured properly. Sometimes we think of encrypting the files or backup files that are very sensitive.

In this simple tutorial, you will be able to learn to make the file secured by using encryption and then decrypt the file if needed.

1. Encryption
Let says we want to encrypt the Sample directory with file name Test-only.doc.
A.  First tar the Sample directory
# tar -cvzf Sample.tar.gz Sample/
B.  Then encrypt the file and input your desired password:
# openssl aes-256-ecb -e -a -in Sample.tar.gz -out Sample.tar.gz.enc
enter aes-256-cbc encryption password:
Verifying – enter aes-256-cbc encryption password:
C. The file will be encrypted with extension of .enc
Sample.tar.gz.enc

2. Decryption
A. You may just decrypt it with:
# openssl aes-256-ecb -d -a -in Sample.tar.gz.enc | tar xvzf –
enter aes-256-ecb decryption password:
B. The Sample directory with file Test-only.doc will then be decrypted and will be extracted
# Sample/Test-only.doc

I hope this simple guide helps you! Cheers

Advertisements