File Password Protection
A > 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.
B > How do I password protect / encrypt a file within Linux using Mcrypt ?
Encrypt File
Use the mcrypt comand to encrypt your file and then test the new file is fully encrypted.
$ mcrypt secretfile.txt
Output:
Enter the passphrase (maximum of 512 characters)
Please use a combination of upper and lower case letters and numbers.
Enter passphrase:
Enter passphrase:
A new file is created with the extension .nc
$ ls secretfile.txt.nc
Decrypt File
Decrypt the file and then confirm the decypted file is readable.
$ mcrypt -d secretfile.txt.nc
Output:
Enter passphrase:
File secretfile.txt.nc was decrypted.
C > How do I password protect / encrypt a file within Linux using GPG ?
Encrypt File
Use the gpg comand to encrypt your file and then test the new file is fully encrypted.
$ gpg -c secretfile.txt
Output:
Enter passphrase:
Repeat passphrase:
This will create a secretfile.txt.gpg file.
Decrypt File
Decrypt the file and then confirm the decypted file is readable.
$ gpg secretfile.txt.gpg
Decrypt file and write output to file
$ gpg secretfile.txt.gpg -o somefile.txt
Easier method is to create a file using vim with the -x flag
vim -x
-
Recent
- Set Time Zone + Fedora 18
- Fedora 17 + Tata Photon (Huawei)
- Fedora 17: Install OpenSSH Server
- Change the default keyring password
- Error: Could not stat() command file ‘/usr/local/nagios/var/rw/nagios.cmd’!
- Gnone 3.X adding personal launcher
- Gnome 3.x Change Panel
- KDE remove autostart programs
- GPS on Linux
- Debian Squeeze change root password
- Download YouTube Videos on Linux
- Pidgin + The certificate for omega.contacts.msn.com could not be validated
-
Links
-
Archives
- April 2013 (1)
- September 2012 (2)
- August 2012 (2)
- July 2012 (2)
- November 2011 (1)
- July 2011 (1)
- April 2011 (1)
- January 2011 (1)
- November 2010 (1)
- September 2010 (2)
- July 2010 (3)
- March 2010 (1)
-
Categories
-
RSS
Entries RSS
Comments RSS