But I already Encrypt My Drives...
The latest Ubuntu 14 release makes it very easy to encrypt your hard drives at installation. However, encrypting a drive only protects your data if your computer is turned off. It will not protect your data whilst your computer is running, which for me is 90% of the time. We need a solution whereby our files remain encrypted, and we only decrypt them as and when we need them. This also protects your data, should you decide to transfer it to a friend or host it "in the cloud". For this, we are going to use the GPG (GNU Privacy Guard) tool to encrypt and decrypt our files.
Encryption Method 1 - Passphrase File
In this first method, we are going to write our passphrase to a file, and use that to encrypt/decrypt our files. The great thing about this is that it should not show your passphrase in the process list, which would be an issue if it is a multi-user system.
Create a passphrase for which you are going to encrypt your files with:
echo "my awesomely amazing passphrase goes here" > $HOME/passphrase.txt
history -c rm ~/.bash_history
Now encrypt your files using the passphrase.
gpg \ --cipher-algo AES256 \ --no-use-agent \ --passphrase-file "$HOME/passphrase.txt" \ --symmetric \ [filename here]
Encryption Method 2 - Enter Passphrase Interactively
In my opinion, this is the simplest/recommended solution, and it removes the possibility of forgetting to delete the passphrase file which somebody else might find at a later date. It also does not require you to clear your history.
Encrypt your file and enter the passphrase when prompted:
gpg \ --cipher-algo AES256 \ --no-use-agent \ --symmetric \ [filename here]
Encryption Method 3 - Specify Passphrase In Command
This method is useful for scripts whereby you cannot interactively enter the encryption password. However, this is unsafe to use on machines with multi-user access as the passphrase will appear in the currently executing process list.
Encrypt your file and enter the passphrase when prompted:
gpg \ --cipher-algo AES256 \ --no-use-agent \ --symmetric \ --passphrase "my passphrase here" \ [filename here]
Decryption Method 1 - Passphrase File
Here is how to decrypt files using a passphrase file.
gpg -d \ --no-use-agent \ --passphrase-file $HOME/passphrase.txt \ secret-file.txt.gpg > secret-file.txt
Decryption Method 2 - Enter Passphrase
Decrypt without
gpg -d \ --no-use-agent \ secret-file.txt.gpg > secret-file.txt
Decryption Method 3 - Specify Passphrase In Command
gpg -d \ --no-use-agent \ --passphrase "my passphrase here" \ secret-file.txt.gpg > secret-file.txt
history -c rm ~/.bash_history
No comments:
Post a Comment