GNU/Linux >> Linux の 問題 >  >> Ubuntu

Ubuntu16.04でeCryptfsを使用してディレクトリを暗号化する方法

このチュートリアルでは、eCryptfsを使用してUbuntu 16.04(Xenial Xerus)のディレクトリを暗号化する方法を示します。 eCryptfsは、Linux用のPOSIX準拠のエンタープライズクラスのスタック暗号化ファイルシステムです。これを使用して、基盤となるファイルシステムやパーティションの種類などに関係なく、独自のパーティションを使用しないパーティションやディレクトリを暗号化できます。

1予備メモ

このチュートリアルでは、新しいディレクトリ/ home/secureを暗号化します。これは通常のディレクトリであり、独自のパーティションを使用しません。

2eCryptfsのインストール

eCryptfsは、次のように簡単にインストールできます。

apt-get -y install ecryptfs-utils

3eCryptfsを使用したディレクトリの暗号化

ここで、新しいディレクトリ/ home /secure/を暗号化します。 mkdirコマンドを使用してディレクトリを作成します:

mkdir /home/secure

既存のディレクトリを使用している場合は、そのディレクトリにすでに(暗号化されていない)ファイルが存在する可能性があります。この場合、後で暗号化された/ home / secure /ディレクトリに復元できるように、それらのバックアップを取る必要があります(そうしないと、ディレクトリが暗号化されている間、これらの塗りつぶしにアクセス/読み取ることができません):

cp -pfr /home/secure/ /tmp/

これで、ディレクトリ/ home / secure /をファイルシステムタイプecryptfsでマウントすることで暗号化できます:

mount -t ecryptfs /home/secure /home/secure

これを初めて行うときは、いくつかの質問に答える必要があります:

[email protected]:~# mount -t ecryptfs /home/secure /home/secure
Passphrase: <-- Enter a secure password
Select cipher:
1) aes: blocksize = 16; min keysize = 16; max keysize = 32
2) blowfish: blocksize = 8; min keysize = 16; max keysize = 56
3) des3_ede: blocksize = 8; min keysize = 24; max keysize = 24
4) twofish: blocksize = 16; min keysize = 16; max keysize = 32
5) cast6: blocksize = 16; min keysize = 16; max keysize = 32
6) cast5: blocksize = 8; min keysize = 5; max keysize = 16
Selection [aes]: <-- Press ENTER
Select key bytes:
1) 16
2) 32
3) 24
Selection [16]: <-- 32
Enable plaintext passthrough (y/n) [n]: <-- Press ENTER
Enable filename encryption (y/n) [n]: <-- Press ENTER
Attempting to mount with the following options:
ecryptfs_unlink_sigs
ecryptfs_key_bytes=16
ecryptfs_cipher=aes
ecryptfs_sig=bd28c38da9fc938b
Mounted eCryptfs
[email protected]:~#

ここで選択したデフォルト設定は、ファイルの内容を暗号化しますが、ファイル名は暗号化しません。ファイル名も保護したい場合は、上記のセットアップ中にファイル名の暗号化オプションを有効にしてください。

の出力を見てください
mount

/ home /secure/が暗号化されていることがわかります。

[email protected]:~# mount
sysfs on /sys type sysfs (rw,nosuid,nodev,noexec,relatime)
proc on /proc type proc (rw,nosuid,nodev,noexec,relatime)
udev on /dev type devtmpfs (rw,nosuid,relatime,size=1002992k,nr_inodes=250748,mode=755)
devpts on /dev/pts type devpts (rw,nosuid,noexec,relatime,gid=5,mode=620,ptmxmode=000)
tmpfs on /run type tmpfs (rw,nosuid,noexec,relatime,size=204440k,mode=755)
/dev/mapper/server1--vg-root on / type ext4 (rw,relatime,errors=remount-ro,data=ordered,jqfmt=vfsv0,usrjquota=quota.user,grpjquota=quota.group)
securityfs on /sys/kernel/security type securityfs (rw,nosuid,nodev,noexec,relatime)
tmpfs on /dev/shm type tmpfs (rw,nosuid,nodev)
tmpfs on /run/lock type tmpfs (rw,nosuid,nodev,noexec,relatime,size=5120k)
tmpfs on /sys/fs/cgroup type tmpfs (ro,nosuid,nodev,noexec,mode=755)
cgroup on /sys/fs/cgroup/systemd type cgroup (rw,nosuid,nodev,noexec,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd,nsroot=/)
pstore on /sys/fs/pstore type pstore (rw,nosuid,nodev,noexec,relatime)
cgroup on /sys/fs/cgroup/pids type cgroup (rw,nosuid,nodev,noexec,relatime,pids,nsroot=/)
cgroup on /sys/fs/cgroup/freezer type cgroup (rw,nosuid,nodev,noexec,relatime,freezer,nsroot=/)
cgroup on /sys/fs/cgroup/blkio type cgroup (rw,nosuid,nodev,noexec,relatime,blkio,nsroot=/)
cgroup on /sys/fs/cgroup/hugetlb type cgroup (rw,nosuid,nodev,noexec,relatime,hugetlb,nsroot=/)
cgroup on /sys/fs/cgroup/cpuset type cgroup (rw,nosuid,nodev,noexec,relatime,cpuset,nsroot=/)
cgroup on /sys/fs/cgroup/cpu,cpuacct type cgroup (rw,nosuid,nodev,noexec,relatime,cpu,cpuacct,nsroot=/)
cgroup on /sys/fs/cgroup/net_cls,net_prio type cgroup (rw,nosuid,nodev,noexec,relatime,net_cls,net_prio,nsroot=/)
cgroup on /sys/fs/cgroup/memory type cgroup (rw,nosuid,nodev,noexec,relatime,memory,nsroot=/)
cgroup on /sys/fs/cgroup/perf_event type cgroup (rw,nosuid,nodev,noexec,relatime,perf_event,nsroot=/)
cgroup on /sys/fs/cgroup/devices type cgroup (rw,nosuid,nodev,noexec,relatime,devices,nsroot=/)
systemd-1 on /proc/sys/fs/binfmt_misc type autofs (rw,relatime,fd=27,pgrp=1,timeout=0,minproto=5,maxproto=5,direct)
debugfs on /sys/kernel/debug type debugfs (rw,relatime)
hugetlbfs on /dev/hugepages type hugetlbfs (rw,relatime)
mqueue on /dev/mqueue type mqueue (rw,relatime)
fusectl on /sys/fs/fuse/connections type fusectl (rw,relatime)
/dev/sda1 on /boot type ext2 (rw,relatime,block_validity,barrier,user_xattr,acl)
tmpfs on /run/lxcfs/controllers type tmpfs (rw,relatime,size=100k,mode=700)
devices on /run/lxcfs/controllers/devices type cgroup (rw,relatime,devices,nsroot=/)
perf_event on /run/lxcfs/controllers/perf_event type cgroup (rw,relatime,perf_event,nsroot=/)
memory on /run/lxcfs/controllers/memory type cgroup (rw,relatime,memory,nsroot=/)
net_cls,net_prio on /run/lxcfs/controllers/net_cls,net_prio type cgroup (rw,relatime,net_cls,net_prio,nsroot=/)
cpu,cpuacct on /run/lxcfs/controllers/cpu,cpuacct type cgroup (rw,relatime,cpu,cpuacct,nsroot=/)
cpuset on /run/lxcfs/controllers/cpuset type cgroup (rw,relatime,cpuset,nsroot=/)
hugetlb on /run/lxcfs/controllers/hugetlb type cgroup (rw,relatime,hugetlb,nsroot=/)
blkio on /run/lxcfs/controllers/blkio type cgroup (rw,relatime,blkio,nsroot=/)
freezer on /run/lxcfs/controllers/freezer type cgroup (rw,relatime,freezer,nsroot=/)
pids on /run/lxcfs/controllers/pids type cgroup (rw,relatime,pids,nsroot=/)
name=systemd on /run/lxcfs/controllers/name=systemd type cgroup (rw,relatime,xattr,release_agent=/lib/systemd/systemd-cgroups-agent,name=systemd,nsroot=/)
lxcfs on /var/lib/lxcfs type fuse.lxcfs (rw,nosuid,nodev,relatime,user_id=0,group_id=0,allow_other)
tmpfs on /run/user/1000 type tmpfs (rw,nosuid,nodev,relatime,size=204440k,mode=700,uid=1000,gid=1000)
tmpfs on /run/user/0 type tmpfs (rw,nosuid,nodev,relatime,size=204440k,mode=700)
/home/secure on /home/secure type ecryptfs (rw,relatime,ecryptfs_sig=bd28c38da9fc938b,ecryptfs_cipher=aes,ecryptfs_key_bytes=32,ecryptfs_unlink_sigs)
[email protected]:~#

既存のディレクトリを使用する場合:バックアップを暗号化されたディレクトリ/ home / secure /に復元し、後でバックアップを削除しましょう:

cp -pfr /tmp/secure/ /home/
rm -fr /tmp/secure/

テストの目的で、他のファイルをコピーしてみましょう。 / etc / hosts、/ home / secure /に移動して、実際に暗号化されているかどうかを確認します:

cp /etc/hosts /home/secure

/ home / secure /はecryptfsファイルシステムタイプでマウントされていますが、/ home / secure / hostsの内容を読み取ることができるはずです:

cat /home/secure/hosts

/ home / secure / ...

のマウントを解除します
umount /home/secure

...そして/home/ secure / hostsをもう一度読んでみてください。そうすれば、謎めいたものを手に入れるはずです:

cat /home/secure/hosts

  • eCryptfs:https://launchpad.net/ecryptfs
  • Debian:http://www.debian.org/

Ubuntu
  1. DebianSqueezeでeCryptfsを使用してディレクトリ/パーティションを暗号化する方法

  2. Ubuntu20.04でLet'sEncryptを使用してNginxを保護する方法

  3. Ubuntu18.04でLetsEncryptを使用してApacheを保護する方法

  1. Ubuntu 20.04/18.04でLetsEncryptを使用してNginxを保護する方法

  2. Ubuntu18.04でLet'sEncryptを使用してNginxを保護する-その方法は?

  3. Apacheを使用してUbuntu20.04にLet’sEncryptをインストールする方法

  1. Ubuntu18.04でSSLを暗号化してApacheSubversionをセットアップする方法

  2. Ubuntu16.04LTSでTombを使用してファイルを暗号化する方法

  3. Apache2でJoomlaをインストールし、Ubuntu20.04で暗号化する方法