eCryptfs

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

関連記事

この記事では eCryptfs の基本的な使い方を説明します。プライベートな暗号化ディレクトリを $HOME ディレクトリに作成して機密ファイルや個人情報を保存する方法を解説していきます。

ブロックデバイスの暗号化レイヤーを提供する dm-crypt とは異なり eCryptfs はファイルシステムそのものです – スタック暗号化ファイルシステム になります。その違いについてはディスク暗号化#比較表を参照してください。大きな特徴として既存のファイルシステム上に暗号化が積み重ねられるという点が挙げられます。eCryptfs はあらゆる既存のディレクトリにマウントすることができ、特別なパーティション (や領域の事前割り当て) を必要としません。

基本

先に述べたように eCryptfs には特殊なパーティションや予約済みの領域をディスク上に配置する必要がありません。代わりに、eCryptfs を既存のディレクトリ上にマウントしてディレクトリを保護することができます。例えば、ユーザーの $HOME ディレクトリを全体的に保護したり、逆に特定のディレクトリだけを保護したりできます。暗号のメタデータは全てファイルのヘッダの中に保存されます。つまり、暗号化したデータは簡単に移動したり、バックアップ・復元できるということです。他にも利点はありますが、欠点も存在します。例として eCryptfs はパーティション全体を暗号化するのには適していません。また、スワップ領域を eCryptfs で保護することは不可能です (もちろん、Dm-crypt/スワップの暗号化と組み合わせることはできますが)。ディスク暗号化を初めて設定する場合、スワップの暗号化などのポイントはディスク暗号化#準備に書かれています。

eCryptfs を使うなら以下がポイントです:

  • スタックファイルシステムとして、eCryptfs ディレクトリのマウントは (スタックされた) 暗号化ディレクトリを他の暗号化されていないマウントポイント (ディレクトリ) マウントすることを意味します。
  • ユーザー間で暗号化ディレクトリを共有することができます。ただし、暗号化のパスワードは一つだけなのでパスワードも共有する必要があります。(別々のパスフレーズを使って) 別々に暗号化されたファイルを一つのディレクトリで共有することもできます。
  • ドキュメントの中では eCryptfs の専門用語が頻繁に登場します:
    • eCryptfs のドキュメントやこの記事では暗号化されるディレクトリは lower (下層) と呼称して暗号化されていないディレクトリは upper (上層) ディレクトリと呼びます。この記事とは無関係ですが、Linux 3.18 で導入された "overlay" ファイルシステム ([1]) では同じ upper/lower という単語をファイルシステムのスタック化について使います。
    • マウントパスフレーズ (キー) は暗号化されたファイルへのアクセス権限を与えます。つまり暗号化を解除します。eCryptfs は wrapped という言葉を使って暗号的に安全なマウントパスフレーズを示します。
    • FEFEKFile's Encryption key Encryption Key のことです (カーネルドキュメント を参照)。
    • FNEKFile Name Encryption Key のことです。暗号化ディレクトリに保存されたファイル名を暗号化する鍵になります (任意)。

eCryptfs を使う前に、以下の欠点が障害にならないか確認してください。

欠陥

  • 使いやすさ
eCryptfs の使いやすさは主として ecryptfs-utils パッケージの "Ubuntu tools" に依存しています。決定的な欠点として、ツールの中では多数の変数 (暗号化オプションやディレクトリパス) が決め打ちされています。変数を変更するとなると大変面倒な手動設定が必要ということです。
  • ファイル名の長さ
143文字よりも長いファイル名は暗号化できません (FNEK オプションを使用した場合 [2])。一部のプログラムがホームディレクトリで動作しなくなる可能性があります (例: Symfony のキャッシュ)。
  • ネットワークストレージマウント
eCryptfs にはネットワークストレージに関する長年の バグ や機能リクエストが存在します。暗号化したディレクトリの中身をネットワークのバックアップストレージに複製することは可能です。しかしながら、ネットワークストレージ上に直接、暗号化ディレクトリを保存してそれをローカルでマウントしたい場合、まずネットワークツール (NFS や Samba など) に対応した解決方法を検索する必要があります。よく分からない場合、EncFS を使うのがベターです。
  • スパースファイル
eCryptfs はスパースファイルを扱うことができません。バグと言われることもありますが、スタックファイルシステムの暗号化として当然そうなるべきことです。例えば、eCryptfs ディレクトリに truncate -s 1G file.img で 1GB の暗号化データを作成してファイルシステムに保存する場合、それに対応するリソース (ディスク容量, データのスループット) が必要になります。暗号化しなければ、同じファイルをスパースファイルとして効率的にファイルシステムに保存できます。ブロックデバイスの暗号化はファイルシステムの出力だけを暗号化します。
巨大なディレクトリ構造を暗号化するときは予めこのことを考えておく必要があります。大抵の場合、スパースファイルを使えないことが致命的な問題になることはありません。(eCryptfs の標準の .Private ディレクトリではなく) 暗号化を施さない .Public ディレクトリにスパースファイルを保存する方法と、.Publicdm-crypt' のコンテナを使う方法があります。

セットアップ & マウント

セットアップを始める前に、eCryptfs のドキュメントを確認してください。素晴らしい マニュアルページ が付属しています。

eCryptfs はバージョン 2.6.19 から Linux に含まれています。ecryptfs モジュールをロードしてからセットアップに進みます:

# modprobe ecryptfs

eCryptfs ファイルシステムをマウントするには、ecryptfs-utils パッケージに含まれているユーザースペースツールが必要です。残念ながら、ツールの設計上、それぞれ長短のある以下の3つから eCryptfs を設定する方法を選択する必要があります:

  1. Ubuntu のツールを使用する。設定を自動的に行うことができますが、ディレクトリは ~/.Private/ に決め打ちになり、ユーザーごとにひとつしか暗号化ファイルシステムを作成できません。
  2. ecryptfs-simple を使用する。下層ディレクトリと上層ディレクトリを使って eCryptfs ファイルシステムを簡単にマウントすることができます。
  3. パスフレーズのロードと eCryptfs のマウントを別々に行う手動セットアップ。ディレクトリや暗号化設定を完全に制御できます。

Ubuntu のツールを使う

ecryptfs-utils パッケージでインストールされるユーザーフレンドリで便利なツールは特殊な eCryptfs セットアップを使います。つまり Ubuntu によって公式で使われているセットアップです (ディストリのインストール時にオプションとして選択できます)。残念ながら、デフォルトのオプションは使われずにツールにハードコードされています。このセットアップがあなたに合わない場合、便利なツールを使うのを諦めて #手動セットアップ を行う必要があります。

ツールで使われるセットアップとは以下になります:

  • ツールで管理できる暗号化ディレクトリはユーザーごとに一つずつになります:
    • $HOME ディレクトリを完全に暗号化する。あるいは、
    • 単一の暗号化データディレクトリ (デフォルトでは ~/Private/ ですがカスタマイズできます)。
  • ユーザー各自の下層ディレクトリ~/.Private/ になります。
    (ホームディレクトリを暗号化する場合、/home/.ecryptfs/$USER/.Private/ へのシンボリックリンクになります)
  • 使用される暗号化オプション:
    • 暗号: AES
    • 鍵長: 16 バイト (128 ビット)
    • 鍵の管理方式: パスフレーズ
    • プレーンテキストパススルー: 有効
  • 暗号化ディレクトリの設定や制御情報は ~/.ecryptfs/ のファイルに保存されます:
    (ホームディレクトリを暗号化する場合、/home/.ecryptfs/$USER/.ecryptfs/ へのシンボリックリンクになります)
    • Private.mnt [プレーンテキストファイル] - 上層ディレクトリをマウントするパスが記述されます (例: /home/lucy/home/lucy/Private)。
    • Private.sig [プレーンテキストファイル] - カーネルのキーリングでマウントパスフレーズを確認するのに使われる署名。
    • wrapped-passphrase [バイナリファイル] - マウントパスフレーズ。ログインパスフレーズで暗号化されます。
    • auto-mount, auto-umount [空のファイル] - ファイルが存在する場合、ユーザーのログイン・ログアウト時に pam_ecryptfs.so モジュールが (ロードされていれば) 自動的に暗号化ディレクトリをマウント・アンマウントします。

データディレクトリの暗号化

$HOME ディレクトリを暗号化する場合は #ホームディレクトリの暗号化 を見て下さい。

データディレクトリの暗号化をセットアップする前に、手動でマウントするか、ユーザーのログイン時に自動的にマウントするか決めておいて下さい。

一人一個のデータディレクトリを暗号化して手動でマウントする場合、次を実行:

$ ecryptfs-setup-private --nopwcheck --noautomount 

指示に従って下さい。--nopwcheck オプションが付いているのでユーザーのログインパスフレーズ以外のパスフレーズを選択することができます。--noautomount オプションはその名の通りです。つまり、ログイン時に自動的に暗号化ディレクトリをマウントするようにセットアップしたい場合、両方のオプションを取り除いて実行してください。

スクリプトは先に述べた ~/.Private/~/.ecryptfs/ ディレクトリを自動的に作成します。2つのパスフレーズが要求されます:

ログインパスフレーズ
暗号化ディレクトリをマウントするたびに入力する必要があるパスワードです。ログイン時に自動マウントさせる場合、ユーザーアカウントにログインするときに使うのと同じパスワードでなくてはなりません。
マウントパスフレーズ
ファイル暗号化のマスターキーを取得するのに使われます。そのため、よく分からない場合は自分で入力してはいけません。Enter を押せば勝手にランダムなパスフレーズが自動生成されます。ログインパスフレーズを使って暗号化され ~/.ecryptfs/wrapped-passphrase に保存されます。必要になったときに RAM で自動的に復号化されるため ("unwrapped")、手動で入力する必要は二度とありません。このファイルが消えてしまうと、暗号化フォルダに永久にアクセスできなくなります。暗号化されていないマウントパスフレーズは ecryptfs-unwrap-passphrase を実行することで確認できます。紙に書き写して、金庫 (など) に保管しておくのが良いでしょう。書き写したパスフレーズを使えば、何らかの理由で wrapped-passphrase ファイルが消失・破損してしまった場合やログインパスフレーズを忘れてしまった場合に暗号化データを復元することができます。

暗号化ディレクトリのマウントポイント ("上層ディレクトリ") はデフォルトでは ~/Private となっていますが、セットアップコマンドを実行した後に以下を実行することで手動で変更できます:

$ mv ~/Private /path/to/new/folder
$ echo /path/to/new/folder > ~/.ecryptfs/Private.mnt

実際に暗号化フォルダを使うには、マウントする必要があります。下の #マウント を見て下さい。

ホームディレクトリの暗号化

ecryptfs-migrate-home スクリプトは特定のユーザーの $HOME に暗号化ディレクトリをセットアップして、暗号化されていないホームディレクトリに存在する既存のファイルを自動的に移動します。設定するユーザーはログアウトしていること、ユーザーのプロセスが存在しないことを確認してください (ps -U username で何も出力されないことをチェックしてください)。問題ないようでしたら、以下を実行:

# modprobe ecryptfs
# ecryptfs-migrate-home -u username

そして指示に従って下さい。ラッパースクリプトを実行したら、自動マウントの設定をしてください。下の #自動マウント を参照。設定を完了するには、再起動するにユーザーがログインする必要があります。

全て設定できたら、/home/username.random_characters に保存されたホームディレクトリのバックアップは削除してかまいません。

マウント

手動

ラッパーを実行:

$ ecryptfs-mount-private

後はパスフレーズを入力するだけで上述上層ディレクトリである ~/Private に暗号化ディレクトリをマウントできます。

同じように、以下を実行するとアンマウントされます:

$ ecryptfs-umount-private
ヒント: ユーザーセッションの間に永続的にプライベートのデータにアクセスする必要がない場合、エイリアスを定義することで高速化できます。

ツールには、暗号化された .Private のデータやホームディレクトリにアクセスするための便利なスクリプトも含まれています。root で ecryptfs-recover-private を実行するとディレクトリが存在しないかシステムが検索されて (あるいはパスを指定することもできます)、インタラクティブにパスフレーズが要求されてディレクトリがマウントされます。ライブ CD や別のシステムから、リカバリを行う時に暗号化データにアクセスするのに使うことができます。Arch Linux ISO から起動する場合、まず ecryptfs-utils をインストールしないと使えないので注意してください。さらに、このスクリプトは Ubuntu ツールで作成した .Private ディレクトリしかマウントできません。

自動マウント

暗号化ディレクトリを自動マウントするデフォルトの方法は PAM です。詳しくは pam_ecryptfs(8) や以下のファイルの 'PAM MODULE' を見て下さい:

/usr/share/doc/ecryptfs-utils/README

自動でマウントするには、暗号化ディレクトリにアクセスするためのパスフレーズとユーザーがログイン時に使用するパスフレーズが一致している必要があります。

以下の手順でセットアップします:

1. ~/.ecryptfs/auto-mount, ~/.ecryptfs/auto-umount, ~/.ecryptfs/wrapped-passphrase が存在することを確認してください (ecryptfs-setup-private によって自動的に作成されます)。

2. 以下のように pam に ecryptfs を追加することでログイン時に透過的にパスフレーズが解除されるようにします:

/etc/pam.d/system-auth を開いて auth required pam_unix.so と書かれた行の後ろに以下を追加:

auth    required    pam_ecryptfs.so unwrap

次に、password required pam_unix.so と書かれた行のに以下を挿入:

password    optional    pam_ecryptfs.so

最後に、session required pam_unix.so という行のに以下を追加:

session    optional    pam_ecryptfs.so unwrap

3. 再ログインして mount の出力を確認します。以下のようにユーザーの暗号化ディレクトリのマウントポイントが表示されるはずです:

/home/$USER/.Private on /home/$USER/Private type ecryptfs (...)

これで自動的に ~$HOME/Private/ を読めるようになります。

ディレクトリはユーザーのログオフ時に自動的にアンマウントされて読めなくなります。

ノート: The above changes to system-auth enable auto-mounting for normal login. If you switch users instead, using su - or su -l, you need to apply similar changes also to /etc/pam.d/su-l.
警告: Unfortunately the automatic unmounting is susceptible to break with systemd and bugs are filed against it.[3] [4] [5] [6] If you experience this problem, you can test it by commenting out -session optional pam_systemd.so in /etc/pam.d/system-login. However, this is no solution because commenting out will break other systemd functionalities.

ecryptfs-simple を使う

EncFS と同じように任意のディレクトリをマウントすることだけに eCryptfs を使う場合 ecryptfs-simple を使って下さい。ecryptfs-simple は root 権限を必要とせず /etc/fstab にエントリを書く必要もありません。さらに ~/.Private などのディレクトリにハードコードもされていません。ecryptfs-simpleAURXyne のリポジトリ からパッケージをインストールできます。

名は体を表すとおり、使用方法はシンプルです:

# simple mounting
ecryptfs-simple /path/to/foo /path/to/bar
# automatic mounting: prompts for options on the first mount of a directory then reloads them next time
ecryptfs-simple -a /path/to/foo /path/to/bar
# unmounting by source directory
ecryptfs-simple -u /path/to/foo
# unmounting by mountpoint
ecryptfs-simple -u /path/to/bar

手動セットアップ

以下では eCryptfs による暗号化ディレクトリを手動でセットアップする方法を説明します。設定は2段階で行います。まず、パスフレーズをカーネルのキーリングにロードします。そして、キーリングのキーを使ってファイルシステムをマウントします。

カーネルのキーリングにパスフレーズを追加する方法は2つ存在します。簡単なのは ecryptfs-add-passphrase で、ひとつのパスフレーズを使ってファイルを暗号化します。デメリットとしてパスフレーズを後から変更することはできません。以下のように使用します:

$ ecryptfs-add-passphrase
Passphrase: 
Inserted auth tok with sig [78c6f0645fe62da0] into the user session keyring

ecryptfs-add-passphrase - にパスフレーズをパイプで渡すこともできます。パスフレーズをファイルの中に書いてしまったら、暗号化を使う意味がなくなるので注意してください。

As an alternative to a plain passphrase, you can use a "wrapped passphrase", where the files are encrypted using a randomly generated key, which is itself encrypted with your passphrase and stored in a file. In this case, you can change your passphrase by unwrapping the key file with your old passphrase and rewrapping it using your new passphrase.

In the following we do a generation similar to the source and then use ecryptfs-wrap-passphrase to wrap it with the password ("Arch") to ~/.ecryptfs/wrapped-passphrase:

$ printf "%s\n%s" $(od -x -N 100 --width=30 /dev/random | head -n 1 | sed "s/^0000000//" | sed "s/\s*//g") "Arch" | ecryptfs-wrap-passphrase /home/username/.ecryptfs/wrapped-passphrase

Next, we can enter our passphrase "Arch" to load the key into the keyring:

$ printf "%s" "Arch" | ecryptfs-insert-wrapped-passphrase-into-keyring /home/username/.ecryptfs/wrapped-passphrase -
Inserted auth tok with sig [7c5d3dd8a1b49db0] into the user session keyring

In either case, when you successfully add the passphrase to the kernel keyring, you will get a "key signature" like 78c6f0645fe62da0 which you will need in the next step.

There are two different ways of manually mounting eCryptfs, described in the following sections. The first way, using mount.ecryptfs_private, can be run as a regular user and involves setting up some configuration files. This method does not allow you to change the encryption settings, such as key size. The second way is to use a raw mount command, which gives you complete control over all settings, but requires you to either run it as root, or add an entry to /etc/fstab which lets a user mount eCryptfs.

ヒント: The following examples use an encrypted directory (.secret) different to the default, hard-coded .Private in the Ubuntu tools. This is on purpose to avoid problems of erroneous #Auto-mounting when the system has PAM setup for it, as well as problems with other tools using the hard-coded defaults.

ecryptfs-utils を使う

This method involves running mount.ecryptfs_private from the ecryptfs-utils package, after first loading your passphrase. This binary requires no root privileges to work by default.

First choose a name for your configuration files in ~/.ecryptfs and decide on the lower and upper directories. In this example we use secret for the configuration files, put in encrypted data in ~/.secret, and mount the decrypted files at ~/secret. Create the required directories:

$ mkdir ~/.secret ~/secret ~/.ecryptfs

Now specify the directories in ~/.ecryptfs/secret.conf, using full paths. Its format looks like the one in /etc/fstab without the mount options:

$ echo "$HOME/.secret $HOME/secret ecryptfs" > ~/.ecryptfs/secret.conf

Write the key signature you got from ecryptfs-add-passphrase or ecryptfs-insert-wrapped-passphrase-into-keyring (see above) into ~/.ecryptfs/secret.sig:

$ echo 78c6f0645fe62da0 > ~/.ecryptfs/secret.sig

If you also want to enable filename encryption, add a second passphrase to the keyring (or reuse the first passphrase) and append its key signature to ~/.ecryptfs/secret.sig:

 $ echo 326a6d3e2a5d444a >> ~/.ecryptfs/secret.sig

Finally, mount ~/.secret on ~/secret:

$ mount.ecryptfs_private secret

When you are done, unmount it:

$ umount.ecryptfs_private secret

ecryptfs-utils を使わない

By running the actual mount command manually, you get complete control over the encryption options. The disadvantage is that you need to either run mount as root, or add an entry to /etc/fstab for each eCryptfs directory so users can mount them.

First create your private directories. In this example, we use the same ones as the previous section:

$ mkdir -m 700 ~/.secret
$ mkdir -m 500 ~/secret

To summarize:

  • Actual encrypted data will be stored in the lower ~/.secret directory
  • While mounted, decrypted data will be available in ~/secret directory
    • While not mounted nothing can be written to this directory
    • While mounted it has the same permissions as the lower directory

Now, supposed you have created the wrapped keyphrase above, you need to insert the encryption key once to the root user's keyring:

# printf "%s" "Arch" | ecryptfs-insert-wrapped-passphrase-into-keyring /home/username/.ecryptfs/wrapped-passphrase -
Inserted auth tok with sig [7c5d3dd8a1b49db0] into the user session keyring

so that the followng mount command succeeds:

# mount -i -t ecryptfs ~/.secret ~/secret -o ecryptfs_sig=7c5d3dd8a1b49db0,ecryptfs_fnek_sig=7c5d3dd8a1b49db0,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_unlink_sigs
  • ecryptfs_sig sets the data passphrase key signature.
  • ecryptfs_fnek_sig sets the filename passphrase key signature; you can omit this option if you do not want to encrypt filenames.
  • ecryptfs_key_bytes can be 16, 24, or 32 to change the encryption key size.
  • ecryptfs_unlink_sigs will remove the passphrase(s) from the keyring when you unmount, so you have to add the passphrase(s) back again in order to re-mount the filesystem.
  • There are a few other options listed in the ecryptfs man page.
ヒント: There is a mount.ecryptfs tool, which you can run as root to enter the mount settings interactively. Once you have used it to mount eCryptfs, you can check /etc/mtab to find out what options it used.

Once you have chosen the right mount options, you can add an entry to /etc/fstab so regular users can mount eCryptfs on these directories. Copy the mount options to a new /etc/fstab entry and add the options user and noauto. The full entry will look similar to (bold entries added):

/etc/fstab
/home/username/.secret /home/username/secret ecryptfs noauto,user,ecryptfs_sig=7c5d3dd8a1b49db0,ecryptfs_fnek_sig=7c5d3dd8a1b49db0,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_unlink_sigs 0 0
  • The noauto option is important, because otherwise systemd will error trying to mount the entry directly on boot.
  • The user option enables to mount the directory as a user.
    • The user mount will default to option noexec. If you want to have at least executable files in your private directory, you can add exec to the fstab options.

The setup is now complete and the directory should be mountable by the user.

マウント

To mount the encrypted directory as the user, the passphrase must be unwrapped and made available in the user's keyring. Following above section example:

$ ecryptfs-insert-wrapped-passphrase-into-keyring /home/username/.ecryptfs/wrapped-passphrase
Passphrase: 
Inserted auth tok with sig [7c5d3dd8a1b49db0] into the user session keyring 

Now the directory can be mounted without the mount helper questions:

$ mount -i /home/username/secret

and files be placed into the secret directory. The above two steps are necessary every time to mount the directory manually.

To unmount it again:

$ umount /home/username/secret

To finalize, the preliminary passphrase to wrap the encryption passphrase may be changed:

$ ecryptfs-rewrap-passphrase /home/username/.ecryptfs/wrapped-passphrase
Old wrapping passphrase: 
New wrapping passphrase: 
New wrapping passphrase (again):

The un-mounting should also clear the keyring, to check the user's keyring or clear it manually:

$ keyctl list @u
$ keyctl clear @u
ノート: One should remember that /etc/fstab is for system-wide partitions only and should not generally be used for user-specific mounts
自動マウント

Different methods can be employed to automount the previously defined user-mount in /etc/fstab on login. As a first general step, follow point (1) and (2) of #Auto-mounting.

Then, if you login via console, a simple way is to specify the user-interactive mount and umount in the user's shell configuration files, for example Bash#Configuration files.

Another method is to automount the eCryptfs directory on user login using pam_mount. To configure this method, add the following lines to /etc/security/pam_mount.conf.xml:

<luserconf name=".pam_mount.conf.xml" />
<mntoptions require="" /> 
<lclmount>mount -i %(VOLUME) "%(before=\"-o\" OPTIONS)"</lclmount> 

Please prefer writing manually these lines instead of simply copy/pasting them (especially the lclmount line), otherwise you might get some corrupted characters. Explanation:

  • the first line indicates where the user-based configuration file is located (here ~/.pam_mount.conf.xml)
  • the second line overwrites the default required mount options which are unnecessary ("nosuid,nodev")
  • the last line indicates which mount command to run (eCryptfs needs the -i switch).

Then set the volume definition, preferably to ~/.pam_mount.conf.xml:

<pam_mount>
    <volume noroot="1" fstype="ecryptfs" path="/home/user/.secret/" mountpoint="/home/user/secret/"/>
</pam_mount>

"noroot" is needed because the encryption key will be added to the user's keyring.

Finally, edit /etc/pam.d/login as described in pam_mount's article.

任意のステップ

To avoid wasting time needlessly unwrapping the passphrase you can create a script that will check pmvarrun to see the number of open sessions:

#!/bin/sh
#
#    /usr/local/bin/doecryptfs

exit $(/usr/sbin/pmvarrun -u$PAM_USER -o0)

With the following line added before the eCryptfs unwrap module in your PAM stack:

auth    [success=ignore default=1]    pam_exec.so     quiet /usr/local/bin/doecryptfs
auth    required                      pam_ecryptfs.so unwrap

The article suggests adding these to /etc/pam.d/login, but the changes will need to be added to all other places you login, such as /etc/pam.d/kde.

使用方法

暗号化ディレクトリにシンボリックリンクを作成

プライベートディレクトリを重要なファイルやプライベートなデータを保存する場所として使う以外に、アプリケーションのデータを保護するのに使うことも可能です。例えば Firefox にはパスワードマネージャが組み込まれていますが、ブラウザの履歴やキャッシュなども機密情報と言えます。簡単に保護できます:

 $ mv ~/.mozilla ~/Private/mozilla
 $ ln -s ~/Private/mozilla ~/.mozilla

暗号化の解除

プライベートディレクトリを削除するときに、特別な手順は必要ありません。アンマウントされていることを確認してから、暗号化ファイルが入っている下層ディレクトリ (例: ~/.Private) を削除してください。~/.ecryptfs にある暗号化署名や設定も削除してしまえば、全てが泡と消えます。

#Ubuntu のツールを使う のとおりにディレクトリの暗号化をセットアップした場合、以下を実行することで直接削除できます:

$ ecryptfs-setup-private --undo

指示に従って下さい。

バックアップ

プライベートディレクトリからファイルを外に出したいときは、~/Private をマウントして新しい場所に移動するだけです。

With eCryptfs the cryptographic metadata is stored in the header of the files. Setup variants explained in this article separate the directory with encrypted data from the mount point. The unencrypted mount point is fully transparent and available for a backup. Obviously this has to be considered for automated backups, if one has to avoid leaking sensitive unencrypted data into a backup.

You can do backups, or incremental backups, of the encrypted (e.g. ~/.Private) directory, treating it like any other directory.

その他の注意事項:

  • Ubuntu ツールを使って #データディレクトリの暗号化 をした場合、暗号化したファイルが含まれた低層ディレクトリは通常ユーザーの $HOME から外れた /home/.ecryptfs/$USER/.Private にあるので注意してください。
  • It should be ensured to include the eCryptfs setup files (located in ~/.ecryptfs usually) into the regular or a separate backup.
  • 特殊なファイルシステムのマウントオプションを使用している場合 (例: ecryptfs_xattr)、リストア時に確認をしてください。

参照

  • eCryptfs - Man ページとプロジェクトホーム
  • Security audit of eCryptfs by Taylor Hornby (2014年1月22日)
  • eCryptfs and $HOME by Adrian C. (anrxc) - eCryptfs のインストールと使用方法に関する記事
  • Chromium data protection (2009年11月) - Chromium OS の暗号化オプションに関するドキュメントですが、eCryptfs の使い方についても触れています
  • eCryptfs design by Michael Halcrow (2005年5月) - Original design document detailing and discussing eCryptfs