Home > 8月 31st, 2011

2011.08.31

Ubuntu 11.04 でディレクトリの暗号化

Ubuntu11.04で特定のディレクトリをencfsを使って暗号化する。

インストール。

$ sudo apt-get install encfs

暗号化したディレクトリの作成とmount。

$ encfs ~/.crypt ~/crypt

この例だと、~/.cryptに暗号化されたデータが入り、~/cryptでファイルアクセスできる。
初回は作成だが、作成後は上記コマンドでディレクトリが利用できる。

ディレクトリが存在しない場合作成を聞かれる。

ディレクトリ “/home/hoge/.crypt/” が存在しません。作成しますか? (y,n) y
ディレクトリ “/home/hoge/crypt” が存在しません。作成しますか? (y,n) y
新しい暗号化ボリュームを作成します。

モード聞かれる。よくわからないので何も入力せずエンターでスタンダードモード。

Please choose from one of the following options:
enter “x” for expert configuration mode,
enter “p” for pre-configured paranoia mode,
anything else, or an empty line will select standard mode.
?>

Standard configuration selected.

そしてログが流れ

設定が完了しました。以下のプロパティのファイルシステムが
作成されます:
ファイルシステム暗号アルゴリズム: “ssl/aes”, バージョン 3:0:2
Filename encoding: “nameio/block”, version 3:0:1
鍵サイズ: 192 ビット
Block Size: 1024 bytes
Each file contains 8 byte header with unique IV data.
Filenames encoded using IV chaining mode.
File holes passed through to ciphertext.

Now you will need to enter a password for your filesystem.
You will need to remember this password, as there is absolutely
no recovery mechanism. However, the password can be changed
later using encfsctl.

パスワードを聞かれる。

新しい Encfs パスワード:
Encfs パスワードの確認:

完了。

●mountする方法

$ encfs ~/.crypt ~/crypt
EncFS Password:       # パスワードを入力

●unmountする方法

$ fusermount -u ~/crypt

●パスワードを変更する方法

$ encfsctl passwd ~/.crypt     # 暗号化されたデータが入るディレクトリを指定
Enter current Encfs password
EncFS Password:           # 古いパスワードを入力
Enter new Encfs password
New Encfs Password:         # 新しいパスワードを入力
Verify Encfs Password:         # 新しいパスワードをもう一度入力
Volume Key successfully updated.

●ログイン時に自動で接続させる方法
Ubuntuの場合はautostartを使うとユーザログイン時に実行されそう。

$ cat <<EOF > ~/.config/autostart/encfs.desktop
[Desktop Entry]
Type=Application
Exec=/bin/bash -c “/bin/echo [password] | /usr/bin/encfs -S /home/[hogehoge]/.sec /home/[hogehoge]/sec”
Hidden=false
NoDisplay=false
X-GNOME-Autostart-enabled=true
Name[en_US]=encfs
Name=encfs
EOF

※パスワードをディスク内に書いてしまっています。セキュリティとしては暗号化が無意味になりますのでご注意ください。