TrueCrypt

提供: ArchWiki
2015年2月11日 (水) 16:22時点におけるKusakata (トーク | 投稿記録)による版
ナビゲーションに移動 検索に移動

関連記事

警告: 2014年5月から、TrueCrypt の開発は中止され もはやアップデートや修正は行われない ことになっています。dm-crypttcplay などの他の暗号化プログラムを使用するようにしてください。ただし、Truecrypt のフォーク が計画されているようです。開発中止に関するあらましは [1] を参照してください。他の TrueCrypt フォークである VeraCrypt は開発を継続しています: VeraCrypt は AURveracryptAUR でインストールできます。VeraCrypt のストレージフォーマットはバージョン 1.0f から TrueCrypt のストレージフォーマットと互換性を持つようになっています。

TrueCrypt はフリーでオープンソースのオンザフライ暗号化 (OTFE) プログラムです。TrueCrypt の機能として以下があります:

  • 実際のディスクとしてマウントできる仮想的な暗号化ディスク。
  • ハードディスクパーティションやストレージデバイス/メディアの全てを暗号化。
  • ストレージ暗号化の初期化ベクトルを推測することができる CBC モードよりも安全な LRW モードを全ての暗号化アルゴリズムで使用。
  • 通常の"外殻"の暗号化ボリュームの中に"隠しボリューム"を作成可能。パスフレーズやキーファイルが漏れない限り、隠しボリュームをランダムなデータの中から発見するのは不可能。

TrueCrypt と他のディスク暗号化ソリューションの詳しい比較はディスク暗号化#比較表を見て下さい。

インストール

ノート: For opening and accessing an existing TrueCrypt container cryptsetup is the preferred way, since it is well integrated with the rest of the system. Creating a new TrueCrypt container can be done using truecrypt, after which it can be opened using cryptsetup.

公式リポジトリから truecryptインストールしてください。linux 以外のカーネルを使っている場合は、適当なカーネルモジュールもインストールします。

truecrypt を使って仮想ファイルシステム (例: ファイル) を暗号化する場合は、truecrypt コマンドを実行したときに自動でモジュールがロードされます。

truecrypt を使って物理デバイス (例: ハードディスクや usb ドライブ) を暗号化する場合は、ブートシーケンスの間にモジュールをロードするようにしてください:

/etc/modules-load.d/ にモジュールを追加:

# tee /etc/modules-load.d/truecrypt.conf <<< "truecrypt"
ノート:
  • This didn't work for me (module truecrypt seems to be non-existent now), but adding "loop" module worked
# tee /etc/modules-load.d/truecrypt.conf <<< "loop"
# modprobe loop
  • It does not appear that loading a module applies with TrueCrypt 7.1a, the current version in Arch as of 4/19/2013. The above advice may be outdated with respect to the module, however it is still important to enable FUSE, loop and your encryption algorithm (e.g. AES, XTS, SHA512) in custom kernels.

If you only want to open and access an existing truecrypt container, this can also be done with cryptsetup i.e. without installing Truecrypt.

cryptsetup を使って TrueCrypt コンテナにアクセス

バージョン 1.6 から、cryptsetup は TrueCrypt コンテナをネイティブで開けるようになっており、truecrypt パッケージを必要としません。cryptsetup でコンテナを開くには、次のコマンドを実行してください:

$ cryptsetup --type tcrypt open container-to-mount container-name

Replace container-to-mount with the device file under /dev or the path to the file you wish to open. Upon successful opening, the plaintext device will appear as /dev/mapper/container-name, which you can mount like any normal device.

If you are using key files, supply them using the --key-file option, to open a hidden volume, supply the --tcrypt-hidden option and for a partition or whole drive that is encrypted in system mode use the --tcrypt-system option.

サポートされているオプションなどの詳細は man cryptsetup を見て下さい。

/etc/crypttab を使って自動マウント

バージョン 206 から、systemd/etc/crypttab を使用して起動時に TrueCrypt コンテナを (自動的に) マウントすることをサポートしています。

The following example setup will mount /dev/sda2 in system encryption mode as soon as /mnt/truecrypt-volume is accessed using systemd's automounting logic. The passphrase to open the volume is given in /etc/volume.password. Note that the device file given in /etc/fstab needs to be the one from /dev/mapper/ and not, for example, from /dev/disk/by-uuid/ for automounting logic to kick in. Other than that you can still reliably identify the encrypted volume itself inside of /etc/crypttab using device file names from /dev/disk/.

/etc/crypttab
truecrypt-volume    /dev/sda2    /etc/volume.password    tcrypt-system,noauto

For a standard truecrypt volume, use tcrypt instead of tcrypt-system. And for a hidden one, use tcrypt-hidden.

/etc/fstab
/dev/mapper/truecrypt-volume    /mnt/truecrypt-volume    auto    noauto,x-systemd.automount    0    0

Instead of auto, you can put directly your filesystem, and put usual mount options. It is useful with NTFS for mounting as a normal user.

See man crypttab for more details and options supported.

ファイルを仮想ボリュームとして暗号化

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 -t -c

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

Volume type:
 1) Normal
 2) Hidden
Select [1]: 1
Enter file or device path for new volume: /home/user/EncryptedFile.tc
Enter volume size (bytes - size/sizeK/sizeM/sizeG): 32M
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
Hash algorithm:
 1) RIPEMD-160
 2) SHA-1
 3) Whirlpool
Select [1]: 1  

Filesystem:

1) None
2) FAT
3) Linux Ext2
4) Linux Ext3
5) Linux Ext4

Select [2]:

Enter password for new volume '/home/user/EncryptedFile.tc': *****************************
Re-enter password: *****************************
Enter keyfile path [none]: 
Please type at least 320 randomly chosen characters and then press Enter:
Done: 32.00 MB  Speed: 10.76 MB/s  Left: 0:00:00  
Volume created.

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

$ truecrypt -t /home/user/EncryptedFile.tc /home/user/EncryptedFileFolder
ノート: 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 seeMount volumes as a normal user.

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 -t -d

Again, this will require administrator privileges through the use of sudo. After running it check if the files that are to be encrypted are indeed no longer in the directory. (might want to try unimportant data first) If they are still there, note that rm doesn't make the data unrecoverable.

For more information about truecrypt in general, run:

$ man truecrypt
ノート: As of 1:7.1a-1 dont see a man or info page.

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

物理ボリュームの暗号化

ノート: If you are having problems with the graphical interface, you can run in CLI mode with the -t flag.

キーファイルを使いたい場合は、次のコマンドでファイルを作成します:

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

デフォルトでは、ボリュームを解錠するにはパスフレーズとキーの両方が必要になります。

/dev/sda1 デバイスに新しいボリュームを作成:

# truecrypt --volume-type=normal -c /dev/sda1

ボリュームを /dev/mapper/truecrypt1 にマップ:

# truecrypt -N 1 /dev/sda1

上記のコマンドが使えない場合は次のコマンドでボリュームをマップしてみてください:

# truecrypt --filesystem=none --slot=1 /dev/sda1

お好きなファイルシステムを選択して、通常通りにディスクをフォーマットします。ただしパスには /dev/mapper/truecrypt1 を使います。例えば ext4 の場合:

# mkfs.ext4 /dev/mapper/truecrypt1

ボリュームをマウント:

# mount /dev/mapper/truecrypt1 /media/disk

ボリュームをマップしてマウント:

# truecrypt /dev/sda1 /media/disk

ボリュームをアンマウントしてマップを解除:

# truecrypt -d /dev/sda1

隠しボリュームの作成

先に、物理ボリュームの暗号化で説明されているように、通常の外殻ボリュームを作成してください。

外殻ボリュームを /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.ext4 /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

特殊なファイルシステムのマウント

ノート: Current Versions of truecrypt seem to support NTFS write support by default so the --filesystem flag no longer seems to be necessary.

In the following example I want to mount a ntfs-volume, but TrueCrypt does not 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

fstab でボリュームをマウント

First of all, we need to write a script which will handle the way mounting via fstab is done. Place the following in /usr/bin/mount.truecrypt:

#!/bin/sh
DEV="$1"
MNTPT="$2"
OPTIONS=""
TCOPTIONS=""

shift 3
IFS=','
for arg in $*; do
    case "$arg" in
        system)                   TCOPTIONS=(${TCOPTIONS[*]} --m=system);;
        fs*)                      TCOPTIONS=(${TCOPTIONS[*]} --filesystem=${arg#*=});;
        keyfiles*)                TCOPTIONS=(${TCOPTIONS[*]} --keyfiles=${arg#*=});;
        password*)                TCOPTIONS=(${TCOPTIONS[*]} --password=${arg#*=}) && echo "password triggered" ;;
        protect-hidden*)          TCOPTIONS=(${TCOPTIONS[*]} --protect-hidden=${arg#*=});;
        *)                        OPTIONS="${OPTIONS}${arg},";;

    esac
done

/bin/truecrypt --text --non-interactive ${DEV} ${MNTPT} ${TCOPTIONS[*]} --fs-options="${OPTIONS%,*}"

Also do not forget to make the file executable:

# chmod +x /usr/bin/mount.truecrypt

Finally, add the device to fstab somewhat like this:

/dev/sdb3 /mnt truecrypt fs=vfat,defaults 0 0
ヒント: This script is also provided by the truecrypt-mountAUR package.

通常ユーザーでボリュームをマウント

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

以下のどちらの方法でも Sudo が必要になります。先に進む前に sudo を設定するようにしてください。

方法 1: truecrypt グループを追加

Create a new group called truecrypt and give it the necessary permissions. Any users that belongs 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

You can now add your users to the truecrypt group:

# gpasswd -M first_user,second_user,etc truecrypt
ノート: In order to make these changes active, any user that has been added to the truecrypt group have to logout.

After that, you can mount your device by

# truecrypt --mount /path/to/device /path/to/mountpoint

Default mountpoint is /media/truecrypt1. Normally, it is not necessary to explicitly specify the filesystem of your device using the --filesystem flag.

It is definitely reasonable to give truecrypt some permission masks. Otherwise, every file on your mounted device will be executable. So instead of the above, you can use

# truecrypt --fs-options=users,uid=$(id -u),gid=$(id -g),fmask=0113,dmask=0002 --mount /PATH/TO/DEVICE /PATH/TO/MOUNTPOINT

and add this line to your bash configuration file, ~/.bashrc as an alias:

alias tc1='truecrypt --fs-options=users,uid=$(id -u),gid=$(id -g),fmask=0113,dmask=0002 --mount /path/to/device"" /path/to/mountpoint'

To mount this specific device, use

# tc1

as a normal user.

方法 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/EncryptedFile.tc /home/user/EncryptedFileFolder

ログイン時に自動マウント

Simply add:

$ truecrypt /home/user/Encrypted File.tc /home/user/Encrypted File Folder <<EOF
password
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

The most recent truecrypt has a couple of followup questions. If you have expect installed, this will work (assuming no keyfile and no desire to protect hidden volume), saved to a file with root-only perms called from /etc/rc.local:

#! /bin/bash
expect << EOF
spawn /usr/bin/truecrypt ''/path/to/EncryptedFile'' ''/mount/point''
expect "Enter password"
send "volume password\n"
expect "Enter keyfile"
send "\n"
expect "Protect hidden volume"
send "\n"
expect eof;
EOF

Of course, this isn't as secure as entering your password manually. But for some use cases, such as when your TrueCrypt filesystem is in a file on shared storage, it's better than being unencrypted.

(シャットダウン時に) ボリュームを安全にアンマウントしてマップを解除

You can unmount a specific device by

# truecrypt -d /path/to/mountpoint

or leave away the path to unmount all truecrypt volumes.

If you want your truecrypt device to be unmounted automatically at shutdown, add the following to the file /etc/rc.local.shutdown:

if (/usr/bin/truecrypt --text --list)
then {
/usr/bin/truecrypt -d
sleep 3
}
fi

You can also leave away the sleep command, it is just to give the unmounting some time to complete before the actual shutdown.

systemd を使用している場合、シャットダウン時に truecrypt で暗号化されたファイルシステムを自動的にアンマウントするサービスが systemd/サービス のページにあります。

エラー

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.

Deleted stale lockfile

If you always get a message "Delete stale lockfile [....]" after starting Truecrypt, the Truecrypt process with the lowest ID has to be killed during Gnome log out. Edit /etc/gdm/PostSession/Default and add the following line before exit 0:

kill $(ps -ef | grep truecrypt | tr -s ' ' | cut -d ' ' -f 2)

ユニコードのファイル/フォルダ名の問題

NTFS

(暗号化されていない NTFS パーティションは問題なく扱えるのに) 名前にユニコード文字が含まれているファイルやフォルダが TrueCrypt の NTFS ボリュームで表示されない場合、最初に NTFS-3G ドライバーがインストールされているかどうか確認してください。そして以下のシンボリックリンクを root で作成してください:

ln -s /sbin/mount.ntfs-3g /sbin/mount.ntfs

That will cause TrueCrypt to automatically use this driver for NTFS volumes, having the same effect as the explicit use of

truecrypt --filesystem=ntfs-3g /path/to/volume

via the console.

One may also consider setting e.g.:

rw,noatime

amongst other options in the TrueCrypt GUI (Settings > Preferences > Mount Options).

FAT

Similarly, FAT32 volumes created using Windows may use Unicode rather than ISO 8859-1. In order to use UTF-8 globally, set the mount option:

iocharset=utf8

Alternatively, when mounting volumes locally use:

--fs-options=iocharset=utf8

アンマウントエラー (device mapper)

truecrypt のボリュームをアンマウントしようとすると "device-mapper: remove ioctl failed: Device or resource busy" とメッセージが表示される場合、解決方法は Setting > Preferences > System Integration > Kernel Service から次のボックスにチェックを入れて下さい:

Do not use kernel cryptographic services

マウントエラー (device mapper, truecrypt partition)

truecrypt ボリュームをマウントしようとすると、以下のようなメッセージが表示される場合:

Error: device-mapper: create ioctl failed: Device or resource busy
Command failed

次を実行してください:

# cryptsetup remove /dev/mapper/truecrypt1

Failed to set up a loop device

TrueCrypt ボリュームを作成・マウントしようとすると "Failed to set up a loop device" というメッセージが表示される場合、最近カーネルをアップデートしたのに再起動していないのが原因です。再起動を行えばエラーはなくなるでしょう。

それでもエラーが消えない場合、loop がカーネルモジュールとしてロードされているか確認してください:

$ lsmod | grep loop

loop がロードされていない場合、modprobe loop を実行した後に TrueCrypt のコマンドを実行してみてください。それで上手くいくときは、/etc/modules-load.d のモジュールに loop を追加すると良いでしょう:

# tee /etc/modules-load.d/truecrypt.conf <<< "loop"
ノート: As of udev 181-5, the loop device module is no longer auto-loaded, and the procedure described here is necessary.

With newer kernel versions there are no loop devices created at startup. If there are no loop devices the first time mounting a container file, TrueCrypt fails ("Failed to set up a loop device") but also creates the maximum number of loop devices (usually 256), mounting should now work.

To avoid this you can create a loop device before mounting a file:

# mknod -m 0660 /dev/loop8 b 7 8

This creates /dev/loop8. Or create some loop devices at startup:

# echo "options loop max_loop=8" > /etc/modprobe.d/eightloop.conf

Change max_loop=8 to the number of devices you need.

システムパーティションのパスワードに en_US キーマップが必要

If you are using Xorg (which you most likely are, should you not know what that is), use the following command to use US keymap until restart:

# setxkbmap us

NTFS ボリュームで Permission denied

パーミッションに問題がないのに、ファイルシステムに変更を加えられない場合、NTFS-3G がインストールされていないのが原因のことがあります。NTFS を見て下さい。

参照