File-based encryption for Linux
October 31st, 2007
I have some files (e.g. login data) which I would like to keep encrypted on my disk. For this kind of protection symmetric encryption suites me best. So what do we have on Linux side for a quick and clean symmetric encryption?: ccrypt. Based on the Rijndael block cipher, which is also the base for the Advanced Encryption Standard, ccrypt secures files symmetrically. This means no private keys needed, and the en- and decryption can be done with a single passphrase. I also created to scripts which integrate ccrypt, a command-line tool, into my gnome environment. Because the Rjindael algorithm differs for encryption and decryption a script is needed for both.
1. Install ccrypt.
-
apt-get install ccrypt
2. Create the file ~/.gnome2/nautilus-scripts/decrypt
-
touch ~/.gnome2/nautilus-scripts/decrypt
3. and insert the following content.
-
#####################
-
#!/bin/sh
-
#
-
# This script decrypts file(s) or directories encrypted with ccrypt
-
#
-
# Distributed under the terms of GNU GPL version 2 or later
-
#
-
# We put ccrypt full path in environment variable here to avoid
-
# problems with variables substitution when creatign files
-
CCRYPT_PATH=/usr/bin/ccrypt
-
#
-
quoted=$(echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | awk 'BEGIN { FS = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##)
-
#
-
# Call Gnome Terminal to execute ccrypt
-
gnome-terminal -t "Decrypting File(s)" --hide-menubar -e "$CCRYPT_PATH -d -s -v -t -r -P 'Enter File(s) Decryption Key: ' $quoted"
-
########################
4. Create ~/.gnome2/nautilus-scripts/encrypt
-
touch ~/.gnome2/nautilus-scripts/encrypt
5. and insert this content.
-
#########################
-
#!/bin/sh
-
#
-
# This script encrypts file(s) or directories with ccrypt
-
#
-
# Distributed under the terms of GNU GPL version 2 or later
-
#
-
# We put ccrypt full path in environment variable here to avoid
-
# problems with variables substitution when creatign files
-
CCRYPT_PATH=/usr/bin/ccrypt
-
#
-
quoted=$(echo -e "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" | awk 'BEGIN { FS = "\n" } { printf "\"%s\" ", $1 }' | sed -e s#\"\"##)
-
#
-
# Call Gnome Terminal to execute ccrypt
-
gnome-terminal -t "Encrypting File(s)" --hide-menubar -e "$CCRYPT_PATH -e -s -v -t -r -P 'Enter File(s) Encryption Key: ' $quoted"
Now you should be able to see the scripts when right-clicking on a file under the 'Scripts' entry.







Leave a Reply