GNU/Linux >> Linux の 問題 >  >> Cent OS

CentOS/RHEL 8 で Network Ba​​sed Key Services (NBDE) を使用したディスク暗号化

質問 :clevis (クライアント) と tang (サーバー) を使用して起動時に自動的にロック解除される暗号化された XFS ファイルシステムを作成する方法は?

Red Hat には、Linux Unified Key Setup-on-disk-format (LUKS) によるディスク暗号化が長年組み込まれています。このソリューションは、暗号化のニーズに合わせて簡単に実装および構成できますが、そのキー管理の管理と実用性はサーバーにとってひどいものです.手動で入力する必要がある起動時またはマウント時にパスフレーズが必要です。これにより、このソリューションはシステム管理者にとって頭の痛い問題になります。

RHEL 7.4 以降、RHEL 7.5 での完全なサポートにより、Red Hat は、LUKS ディスクをリモートで有効にするために利用できる追加のコンポーネントを実装しました。これは Network Bound Disk Encryption (NBDE) と呼ばれます。

Network Bound Disk Encryption (NBDE) とは:

  • Linux Unified Key Setup (LUKS) はディスク暗号化の標準です。
  • Cryptsetup はディスク ベースの暗号化を構成し、LUKS のサポートを含みます
  • Tang は、HTTP 経由で暗号化サービスを提供するネットワーク サービスです
  • Clevis は暗号化フレームワークです。 Clevis は、Tang から提供されたキーをパスフレーズとして使用して、LUKS ボリュームのロックを解除できます
  • クライアント clevis は CentOS/RHEL 8 である必要があります。CentOS/RHEL 7 の clevis は機能が制限されており、この投稿では説明されていない別のコマンド セットが必要になるためです。
  • サーバー tang は、CentOS/RHEL 7 または 8 で実行できます

Tang サーバーのセットアップ

1. RPM をインストールします:

# dnf install -y tang

2. 必要なポートがファイアウォールを通過できるようにします:

# firewall-cmd --add-service=http --permanent
# firewall-cmd --reload

3. サービスを有効にします:

# systemctl enable --now tangd.socket

Clevis クライアントのセットアップ

暗号化されたファイルシステムを作成する

1. クライアントに必要なパッケージをインストールします:

# dnf install -y cryptsetup clevis-systemd clevis-luks

2. /dev/xvdc に暗号化されたディスクを作成する:

注意 :xvdc 上のすべてのデータが削除されるため、xvdc が空のドライブであることを確認してください。
# cryptsetup luksFormat --type luks2 --cipher aes-xts-plain64 --key-size 512 --hash sha256 --use-random /dev/xvdc
WARNING!
========
This will overwrite data on /dev/xvdc irrevocably.
Are you sure? (Type uppercase yes): YES
Enter passphrase for /dev/xvdc:
Verify passphrase:

3. ブロック デバイスのロックを解除します:

# cryptsetup --verbose luksOpen /dev/xvdc demodisk
Enter passphrase for /dev/xvdc:
Key slot 0 unlocked.
Command successful.

4. 暗号化されたディスクにファイル システムを作成します。

# mkfs.xfs /dev/mapper/demodisk
meta-data=/dev/mapper/demodisk isize=512 agcount=4, agsize=326656 blks
= sectsz=512 attr=2, projid32bit=1
= crc=1 finobt=1, sparse=1, rmapbt=0
= reflink=1
data = bsize=4096 blocks=1306624, imaxpct=25
= sunit=0 swidth=0 blks
naming =version 2 bsize=4096 ascii-ci=0, ftype=1
log =internal log bsize=4096 blocks=2560, version=2
= sectsz=512 sunit=0 blks, lazy-count=1
realtime =none extsz=4096 blocks=0, rtextents=0

5. 新しいファイルシステムの UUID を特定します:

# blkid -s UUID /dev/mapper/demodisk
/dev/mapper/demodisk: UUID="24f9bfe9-1f6d-491d-8fa2-eab946464166"

6. ファイルシステムの fstab エントリを作成します:

# echo "UUID=24f9bfe9-1f6d-491d-8fa2-eab946464166 /encrypted xfs defaults 0 0" | sudo tee -a /etc/fstab
UUID=24f9bfe9-1f6d-491d-8fa2-eab946464166 /encrypted xfs defaults 0 0

7. ファイルシステムをマウントします:

# mkdir /encrypted
# mount /encrypted

暗号化されたデバイスにリモート キーを追加する

1. キーを表示:

# cryptsetup luksDump /dev/xvdc
LUKS header information
Version: 2
Epoch: 3
Metadata area: 16384 [bytes]
Keyslots area: 16744448 [bytes]
UUID: 47e0d1c3-d74b-41f0-9bc7-5ea367e9cb26
Label: (no label)
Subsystem: (no subsystem)
Flags: (no flags)
Data segments:
0: crypt
offset: 16777216 [bytes]
length: (whole device)
cipher: aes-xts-plain64
sector: 512 [bytes]

Keyslots:
0: luks2
Key: 512 bits
Priority: normal
Cipher: aes-xts-plain64
Cipher key: 512 bits
PBKDF: argon2i
Time cost: 4
Memory: 399588
Threads: 4
Salt: 0d 75 99 50 22 e2 2a 93 82 51 fc 49 6f 54 61 fe
10 b6 24 62 21 2e 07 2b 04 0a 56 c8 03 23 6f 8f
AF stripes: 4000
AF hash: sha256
Area offset:32768 [bytes]
Area length:258048 [bytes]
Digest ID: 0
Tokens:
Digests:
0: pbkdf2
Hash: sha256
Iterations: 30284
Salt: de a0 3f 92 e1 c7 1d 5e 0e 52 65 37 19 84 2b 3c
46 2a ba 56 77 25 78 c3 27 fa 5b 07 e1 9a 25 24
Digest: 5b 95 93 af 0e a9 8d 24 cb 35 1e 77 e5 9f 15 85
eb d1 53 85 5b e4 10 2a 68 d0 11 6b 9b 71 f4 05

2. リモートキーを追加:

# clevis luks bind -d /dev/xvdc tang '{"url":"http://"}'
The advertisement contains the following signing keys:

KlbbdbNpdMrVwrk6hZ1wCCeabOY

Do you wish to trust these keys? [ynYN] Y
Enter existing LUKS password:

3. スロット 1 で Clevis によって使用されている新しいキースロットがあることを示します:

# cryptsetup luksDump /dev/xvdc
LUKS header information
Version: 2
Epoch: 5
Metadata area: 16384 [bytes]
Keyslots area: 16744448 [bytes]
UUID: 47e0d1c3-d74b-41f0-9bc7-5ea367e9cb26
Label: (no label)
Subsystem: (no subsystem)
Flags: (no flags)

Data segments:
0: crypt
offset: 16777216 [bytes]
length: (whole device)
cipher: aes-xts-plain64
sector: 512 [bytes]

Keyslots:
0: luks2
Key: 512 bits
Priority: normal
Cipher: aes-xts-plain64
Cipher key: 512 bits
PBKDF: argon2i
Time cost: 4
Memory: 399588
Threads: 4
Salt: 0d 75 99 50 22 e2 2a 93 82 51 fc 49 6f 54 61 fe
10 b6 24 62 21 2e 07 2b 04 0a 56 c8 03 23 6f 8f
AF stripes: 4000
AF hash: sha256
Area offset:32768 [bytes]
Area length:258048 [bytes]
Digest ID: 0
1: luks2
Key: 512 bits
Priority: normal
Cipher: aes-xts-plain64
Cipher key: 512 bits
PBKDF: argon2i
Time cost: 4
Memory: 508554
Threads: 4
Salt: 21 c8 91 58 22 9f 50 83 77 6f fe 12 0b 3a 66 3c
d2 47 70 88 45 70 5e f1 c1 1e d0 e1 8f 96 97 ce
AF stripes: 4000
AF hash: sha256
Area offset:290816 [bytes]
Area length:258048 [bytes]
Digest ID: 0
Tokens:
0: clevis
Keyslot: 1
Digests:
0: pbkdf2
Hash: sha256
Iterations: 30284
Salt: de a0 3f 92 e1 c7 1d 5e 0e 52 65 37 19 84 2b 3c
46 2a ba 56 77 25 78 c3 27 fa 5b 07 e1 9a 25 24
Digest: 5b 95 93 af 0e a9 8d 24 cb 35 1e 77 e5 9f 15 85
eb d1 53 85 5b e4 10 2a 68 d0 11 6b 9b 71 f4 05

起動時に暗号化されたファイルシステムをマウント

1. 後で使用するために、ブロック デバイスの UUID を特定します。

# blkid -s UUID /dev/xvdc
/dev/xvdc: UUID="47e0d1c3-d74b-41f0-9bc7-5ea367e9cb26"

2. 「/dev/xvdc」で検出された UUID を使用してサービスを有効にします。

# systemctl enable [email protected]
Created symlink /etc/systemd/system/basic.target.wants/[email protected] → /usr/lib/systemd/system/[email protected].

3. 起動中にブロック デバイスのロックを解除します:

# echo "encrypteddisk UUID=47e0d1c3-d74b-41f0-9bc7-5ea367e9cb26 - _netdev" | sudo tee -a /etc/crypttab
encrypteddisk UUID=47e0d1c3-d74b-41f0-9bc7-5ea367e9cb26 - _netdev

4. 起動時にファイルシステムをマウントします:

# vi /etc/fstab

エンティティを変更:

UUID=24f9bfe9-1f6d-491d-8fa2-eab946464166 /encrypted xfs defaults 0 0

へ:

/dev/mapper/encrypteddisk /encrypted xfs _netdev 0 0

5. サーバーを再起動して機能を確認します:

# reboot
# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 1.8G 0 1.8G 0% /dev/shm
tmpfs 1.8G 8.5M 1.8G 1% /run
tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
/dev/mapper/ol_dhcp-root 22G 1.6G 20G 8% /
/dev/xvda1 1014M 221M 794M 22% /boot
tmpfs 365M 0 365M 0% /run/user/0
/dev/mapper/encrypteddisk 5.0G 68M 5.0G 2% /encrypted

オプション:既知のパスフレーズを削除

スロット 0 から既知のパスフレーズを削除し、tang サーバーの使用を義務付けることができます。 tang サーバーにアクセスできない場合、ディスクのロックを解除できず、ファイルシステムにアクセスできません。

1. パスフレーズを削除します:

# cryptsetup --verbose luksRemoveKey /dev/xvdc
Enter passphrase to be deleted:
Key slot 0 unlocked.
Keyslot 0 is selected for deletion.
Key slot 0 removed.
Command successful.

2. Clevis キースロットのみが存在することを示します:

# cryptsetup --verbose luksRemoveKey /dev/xvdc
Enter passphrase to be deleted:
Key slot 0 unlocked.
Keyslot 0 is selected for deletion.
Key slot 0 removed.
Command successful.
# cryptsetup luksDump /dev/xvdc
LUKS header information
Version: 2
Epoch: 6
Metadata area: 16384 [bytes]
Keyslots area: 16744448 [bytes]
UUID: 47e0d1c3-d74b-41f0-9bc7-5ea367e9cb26
Label: (no label)
Subsystem: (no subsystem)
Flags: (no flags)

Data segments:
0: crypt
offset: 16777216 [bytes]
length: (whole device)
cipher: aes-xts-plain64
sector: 512 [bytes]

Keyslots:
1: luks2 
Key: 512 bits
Priority: normal
Cipher: aes-xts-plain64
Cipher key: 512 bits
PBKDF: argon2i
Time cost: 4
Memory: 508554
Threads: 4
Salt: 21 c8 91 58 22 9f 50 83 77 6f fe 12 0b 3a 66 3c
d2 47 70 88 45 70 5e f1 c1 1e d0 e1 8f 96 97 ce
AF stripes: 4000
AF hash: sha256
Area offset:290816 [bytes]
Area length:258048 [bytes]
Digest ID: 0
Tokens:
0: clevis
Keyslot: 1
Digests:
0: pbkdf2
Hash: sha256
Iterations: 30284
Salt: de a0 3f 92 e1 c7 1d 5e 0e 52 65 37 19 84 2b 3c
46 2a ba 56 77 25 78 c3 27 fa 5b 07 e1 9a 25 24
Digest: 5b 95 93 af 0e a9 8d 24 cb 35 1e 77 e5 9f 15 85
eb d1 53 85 5b e4 10 2a 68 d0 11 6b 9b 71 f4 05

3. 再起動して機能を確認します:

# reboot
# df -h
Filesystem Size Used Avail Use% Mounted on
devtmpfs 1.8G 0 1.8G 0% /dev
tmpfs 1.8G 0 1.8G 0% /dev/shm
tmpfs 1.8G 8.5M 1.8G 1% /run
tmpfs 1.8G 0 1.8G 0% /sys/fs/cgroup
/dev/mapper/ol_dhcp-root 22G 1.6G 20G 8% /
/dev/xvda1 1014M 221M 794M 22% /boot
/dev/mapper/encrypteddisk 5.0G 68M 5.0G 2% /encrypted
tmpfs 365M 0 365M 0% /run/user/0


Cent OS
  1. CentOS / RHEL 7 :ネットワーク インターフェイス構成ファイルを使用した静的 IP アドレスの構成

  2. CentOS / RHEL 7 で NetworkManager を無効にする方法

  3. CentOS/RHEL 7 でネットワーク チーミングを構成する方法

  1. CentOS 7 /RHEL7でネットワークブリッジを作成する方法

  2. CentOS/RHEL でネットワーク プリンターを削除する方法

  3. CentOS/RHEL でボンディング ネットワーク構成を削除する方法

  1. CentOS / RHEL 7 :ネットワーク インターフェイス名を変更する方法

  2. CentOS / RHEL 7 :nmcli を使用してネットワーク ボンディング (NIC チーミング) を作成する方法

  3. udev ルールを使用して、CentOS/RHEL でネットワーク アダプターの永続的な NIC 名を構成する