File Password Protection
How do I password protect / encrypt a file within Linux using OpenSSL ?
The file we will encrypt will be the file secretfile.txt.As you can see it is just a plain text file.
Encrypt File
Use the openssl comand to encrypt your file and then test the new file is fully encrypted.
$ openssl aes-256-cbc -salt -in secretfile.txt -out secretfile.txt.aes
enter aes-256-cbc encryption password:
Verifying – enter aes-256-cbc encryption password:
$ cat secretfile.txt.aes
binary data
Decrypt File
Decrypt the file and then confirm the decypted file is readable.
$ openssl aes-256-cbc -d -salt -in secretfile.txt.aes -out secretfile.txt
enter aes-256-cbc decryption password:
$ cat secretfile.txt
This is a secret file that we do not want anyone to read.
====================================== (more…)