Difference between revisions of "TrueCrypt"

From ArchWiki
Jump to: navigation, search
m (moved Truecrypt to TrueCrypt: official name)
m (Do not use -Sy when installing packages)
Line 10: Line 10:
== Installation ==
== Installation ==
Type as root in a terminal:
Type as root in a terminal:
  # pacman -Sy truecrypt
  # pacman -S truecrypt
If you use any kernel other than kernel26 install the corresponding kernel module, e.g. kernel26beyond -> truecrypt-beyond.
If you use any kernel other than kernel26 install the corresponding kernel module, e.g. kernel26beyond -> truecrypt-beyond.

Revision as of 20:54, 28 January 2010

TrueCrypt is a free open source on-the-fly encryption (OTFE) program. Some of its features are:

  • Virtual encrypted disks within files that can be mounted as real disks.
  • Encryption of an entire hard disk partition or a storage device/medium.
  • All encryption algorithms use the LRW mode of operation, which is more secure than CBC mode with predictable initialization vectors for storage encryption.
  • "Hidden volumes" within a normal "outer" encrypted volume. A hidden volume can not be distinguished from random data without access to a passphrase and/or keyfile.


Type as root in a terminal:

# pacman -S truecrypt

If you use any kernel other than kernel26 install the corresponding kernel module, e.g. kernel26beyond -> truecrypt-beyond.

If you are using truecrypt to encrypt a virtual filesystem (e.g. a file), the module will be automatically loaded whenever you run the truecrypt command. You will need the "loop" module though. Add it to the MODULES array in /etc/rc.conf.

If you are using truecrypt to encrypt a physical device (e.g. a hard disk or usb drive), you will likely want to load the module during the boot sequence:

Add the module to /etc/rc.conf:

MODULES=(truecrypt ...)

Encrypting a file as a virtual volume

The following instructions will create a file that will act as a virtual filesystem, allowing you to mount it and store files within the encrypted file. This is a convenient way to store sensitive information, such as financial data or passwords, in a single file that can be accessed from Linux, Windows, or Macs.

To create a new truecrypt file interactively, type the following in a terminal:

$ truecrypt -c

Template:Box Note

Follow the instructions, choosing the default values unless you know what you're doing:

Volume type:
 1) Normal
 2) Hidden
Select [1]: 1
Enter file or device path for new volume: /home/user/myEncryptedFile.tc
 1) FAT
 2) None
Select [1]: 1
Enter volume size (bytes - size/sizeK/sizeM/sizeG): 32M
Hash algorithm:
 1) RIPEMD-160
 2) SHA-1
 3) Whirlpool
Select [1]: 1  
Encryption algorithm:
 1) AES
 2) Blowfish
 3) CAST5
 4) Serpent
 5) Triple DES
 6) Twofish
 7) AES-Twofish
 8) AES-Twofish-Serpent
 9) Serpent-AES
10) Serpent-Twofish-AES
11) Twofish-Serpent
Select [1]: 1
Enter password for new volume '/home/user/myEncryptedFile.tc': *****************************
Re-enter password: *****************************
Enter keyfile path [none]: 
TrueCrypt will now collect random data.
Is your mouse connected directly to computer where TrueCrypt is running? [Y/n]: 
Please move the mouse randomly until the required amount of data is captured...
Mouse data captured: 100%  
Done: 32.00 MB  Speed: 10.76 MB/s  Left: 0:00:00  
Volume created.
[user@host:~] $

You can now mount the new encrypted file to a previously-created directory:

$ truecrypt /home/user/myEncryptedFile.tc /home/user/myEncryptedFileFolder

Note: Truecrypt requires root privileges and as such, running the above command as a user will attempt to use sudo for authentication. To work with files as a regular user, please see the appropriate section below.

Once mounted, you can copy or create new files within the encrypted directory as if it was any normal directory. When you are you ready to re-encrypt the contents and unmount the directory, run:

$ truecrypt -d

Again, this will require administrator privileges through the use of sudo.

For more information about truecrypt in general, run:

$ man truecrypt

Several options can be passed at the command line, making automated access and creation a simple task. The man page is highly recommended reading.

Encrypting a physical volume

If you want to use a keyfile, create one with this command:

 truecrypt --create-keyfile /etc/disk.key

By default both passphrase and key will be needed to unlock the volume.

Create a new volume in the device /dev/sda1:

 truecrypt --type normal -c /dev/sda1

Map the volume to /dev/mapper/truecrypt1:

 truecrypt -N 1 /dev/sda1

If you want to use another file system than ext3 simply format the disk like you normally would, except use the path /dev/mapper/truecrypt1.

 mkfs.ext3 /dev/mapper/truecrypt1

Mount the volume:

 mount /dev/mapper/truecrypt1 /media/disk

Map and mount a volume:

 truecrypt /dev/sda1 /media/disk

Unmount and unmap a volume:

 truecrypt -d /dev/sda1

Creating a hidden volume

First, create a normal outer volume as described above.

Map the outer volume to /dev/mapper/truecrypt1:

 truecrypt -N 1 /dev/sda1

Create a hidden truecrypt volume in the free space of the outer volume:

 truecrypt --type hidden -c /dev/sda1

You need to use another passphrase and/or keyfile here than the one you used for the outer volume.

Unmap the outer truecrypt volume and map the hidden one:

 truecrypt -d /dev/sda1
 truecrypt -N 1 /dev/sda1

Just use the passphrase you chose for the hidden volume and TrueCrypt will automatically choose it before the outer.

Create a file system on it (if you have not already) and mount it:

 mkfs.ext3 /dev/mapper/truecrypt1
 mount /dev/mapper/truecrypt1 /media/disk

Map and mount the outer volume with the hidden write-protected:

 truecrypt -P /dev/sda1 /media/disk

Mount a special filesystem

In my example I want to mount a ntfs-volume, but truecrypt doesn't use ntfs-3g by default (so there is no write access; checked in version 6.1). The following command works for me:

truecrypt --filesystem=ntfs-3g --mount /file/you/want/to/mount

You may also want to mount ntfs volume without execute flag on all files

truecrypt --filesystem=ntfs-3g --fs-options=users,uid=$(id -u),gid=$(id -g),fmask=0113,dmask=0002

Mount volumes as a normal user

TrueCrypt needs root privileges to work: this procedure will allow normal users to use it, also giving writing permissions to mounted volumes.

Both methods below require Sudo. Make sure it is configured before proceeding.

Method 1 (Add a truecrypt group)

Create a new group called truecrypt and give it the necessary permissions. Any users that will belong to that group, will be able to use TrueCrypt.

# groupadd truecrypt

Edit the sudo configuration:

# visudo

Append the following lines at the bottom of the sudo configuration file:

# Users in the truecrypt group are allowed to run TrueCrypt as root.
%truecrypt ALL=(root) NOPASSWD:/usr/bin/truecrypt

Before adding our users to the truecrypt group we still have to do something in order to make mounted volumes writable from normal users. To do this just open the system-wide bashrc file:

# nano /etc/bash/bashrc

And add these few lines to it:

alias tc='sudo truecrypt'
alias tcm='tc -M uid=$(id -u),gid=$(id -g)'

You can now add your users to the truecrypt group:

# gpasswd -a USER_1 truecrypt
# gpasswd -a USER_2 truecrypt

Note: In order to make these changes active, any user that has been added to the truecrypt group have to logout.

Method 2 (sudo simplified)

Simply enable desired user to run truecrypt without a password:

# visudo

Append the following:

USERNAME ALL = (root) NOPASSWD:/usr/bin/truecrypt

alternatively, if you make use of the wheel group:

%wheel ALL = (root) NOPASSWD:/usr/bin/truecrypt

If you have any difficulties with permissions as a normal user, just add the '-u' flag to the truecrypt mount command, for example:

$ truecrypt -u /home/user/myEncryptedFile.tc /home/user/myEncryptedFileFolder

Automatic mount on login

Simply add

$ truecrypt /home/user/myEncryptedFile.tc /home/user/myEncryptedFileFolder <<EOF

to your startup procedure. Do not use the -p switch, this method is more secure. Otherwise everyone can just look up the password via ps and similar tools, as it is in the process name! source


TrueCrypt is already running

If a messagebox TrueCrypt is already running appears when starting TrueCrypt, check for a hidden file in the home directory of the concerned user called .TrueCrypt-lock-username. Substitute username with the individual username. Delete the file and start TrueCrypt again.

Related links