Use NBDE to automatically decrypt a LUKS device at boot time, by using three Tang servers if they are available, and falling back to manual decryption by password if they are not.
Outcomes
Install and configure a Tang server.
Decrypt a LUKS partition with multiple Tang servers.
As the student user on the workstation machine, use the lab command to prepare your environment for this exercise, and to ensure that all required resources are available.
You must complete the the section called “Guided Exercise: Managing Storage Device Encryption with LUKS ” before starting this section.
[student@workstation ~]$ lab start luks-nbde
Instructions
Use Ansible to configure the serverb, serverc, and serverd machines as Tang servers.
Those hosts are in the servers group in the /home/student/nbde_servers.yml inventory file.
Write and run an Ansible Playbook that uses the nbde_server system role to complete this task.
Use a text editor to write the /home/student/nbde_servers.yml Ansible Playbook that configures hosts in the servers group by using the nbde_server system role.
Add the following content:
---
- hosts: servers
become: true
become_method: sudo
vars:
nbde_server_rotate_keys: yes
nbde_server_manage_firewall: true
nbde_server_manage_selinux: true
roles:
- rhel-system-roles.nbde_serverRun the /home/student/nbde_servers.yml Ansible Playbook by using the ansible-playbook command.
Include the --ask-become-pass option to provide the student sudo password interactively.
Use the /home/student/RH415/labs/luks-nbde/inventory inventory file.
[student@workstation ~]$ ansible-playbook \
-i /home/student/RH415/labs/luks-nbde/inventory \
--ask-become-pass ~/nbde_servers.yml
...output omitted...
PLAY RECAP ***********************************************************************************
serverb : ok=26 changed=5 unreachable=0 failed=0 skipped=29 rescued=0 ignored=0
serverc : ok=26 changed=5 unreachable=0 failed=0 skipped=29 rescued=0 ignored=0
serverd : ok=25 changed=5 unreachable=0 failed=0 skipped=30 rescued=0 ignored=0Configure the encrypted partition to automatically decrypt and mount its file system on the /encrypted directory at boot time.
Log in to the servera machine as the student user.
[student@workstation ~]$ ssh student@servera
[student@servera ~]$Change to the root user.
Use student as the password.
[student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#
Edit the /etc/crypttab file to open the encrypted partition at boot time.
Add the following content:
encryptedvdb1 /dev/vdb1 none _netdev
Update the /etc/fstab file to mount the file system in the encrypted partition on the /encrypted directory.
...output omitted...
/dev/mapper/encryptedvdb1 /encrypted xfs _netdev 1 2A problem in /etc/fstab might bring the machine to an unusable state.
If this problem happens, then rebuild the classroom environment.
Return to the workstation machine as the student user.
[root@servera ~]#logout[student@servera ~]$logoutConnection to servera closed. [student@workstation ~]$
Configure the hosts in the clients section in the /home/student/RH415/labs/luks-nbde/inventory Ansible inventory file as NBDE (Clevis) clients.
Write and run an Ansible Playbook that uses the nbde_client system role to complete this task.
Use a text editor to write the /home/student/nbde_clients.yml Ansible Playbook.
Configure hosts in the clients group as NBDE clients of your Tang servers by using the nbde_client system role.
Set the threshold for the minimum number of available Tang servers to three.
Add the following content:
---
- hosts: clients
become: true
become_method: sudo
vars:
nbde_client_bindings:
- device: /dev/vdb1
encryption_password: redhatRHT
servers:
- http://serverb.lab.example.com
- http://serverc.lab.example.com
- http://serverd.lab.example.com
threshold: 3
roles:
- rhel-system-roles.nbde_clientRun the /home/student/nbde_clients.yml Ansible Playbook by using the ansible-playbook command.
Include the --ask-become-pass option to provide the student sudo password interactively.
Use the /home/student/RH415/labs/luks-nbde/inventory inventory file.
[student@workstation ~]$ ansible-playbook \
-i /home/student/RH415/labs/luks-nbde/inventory \
--ask-become-pass ~/nbde_clients.yml
PLAY RECAP ***********************************************************************************
servera : ok=20 changed=9 unreachable=0 failed=0 skipped=1 rescued=0 ignored=0Turn off one of the Tang servers to test manual authentication at boot.
Disable socket activation for the Tang server on serverb.
Reboot servera, one of the NBDE clients.
Verify that the /dev/vdb1 LUKS-encrypted partition on the servera machine is decrypted, and that its file system is mounted automatically on the /encrypted directory, by providing the encrypted partition passphrase at boot time.
The system asks for the passphrase at boot time because only two Tang servers are available.
Log in to the serverb machine as the student user.
You do not need to enter any password.
[student@workstation ]$ ssh student@serverb
[student@serverb ~]$Change to the root user.
Use student as the password.
[student@serverb ]$sudo -i[sudo] password for student:student[root@serverb ~]#
Disable socket activation for the Tang server.
When done, log out of the serverb machine.
[root@serverb ~]#systemctl disable tangd.socket --nowRemoved symlink /etc/systemd/system/multi-user.target.wants/tangd.socket. [root@serverb ~]#logout[student@serverb ~]$logoutConnection to serverb closed. [student@workstation ~]$
Log in to the servera machine as the student user.
You do not need to enter any password.
[student@workstation ]$ ssh student@servera
[student@servera ~]$Change to the root user and reboot the machine.
Use student as the password.
[student@servera ]$sudo -i[sudo] password for student:student[root@servera ~]#reboot
Open the servera console.
The console prompts you to manually enter the passphrase for the encrypted partition.
Enter redhatRHT as the passphrase.
On workstation, log in to servera as the student user.
You do not need to enter any password.
[student@workstation ~]$ ssh student@servera
[student@servera ~]$Use the sudo -i command to change to the root user.
Use student as the password.
[student@servera ~]$sudo -i[sudo] password for student:student[root@servera ~]#
Verify that the file system in the encrypted partition is mounted on the /encrypted directory.
When done, log out of the servera machine.
[root@servera ~]#mount | grep /encrypted/dev/mapper/encryptedvdb1 on /encrypted type xfs (rw,relatime,seclabel,attr2,inode64,noquota,_netdev) [root@servera ~]#logout[student@servera ~]$logout[student@workstation ~]$
Make sure that all the Tang servers are running, to test automatic authentication and decryption at boot.
Enable socket activation for the Tang server on the serverb machine.
Reboot the servera machine to verify that the /dev/vdb1 LUKS-encrypted partition is decrypted and that its file system is mounted automatically on the /encrypted directory.
Log in to the serverb machine as the student user.
You do not need to enter any password.
[student@workstation ]$ ssh student@serverb
[student@serverb ~]$Change to the root user.
Use student as the password.
[student@serverb ]$sudo -i[sudo] password for student:student[root@serverb ~]#
Enable socket activation for the Tang server.
When done, log out of the serverb machine.
[root@serverb ~]#systemctl enable tangd.socket --nowCreated symlink /etc/systemd/system/multi-user.target.wants/tangd.socket → /usr/lib/systemd/system/tangd.socket. [root@serverb ~]#logout[student@serverb ~]$logoutConnection to serverb closed. [student@workstation ~]$
After the servera machine completes the reboot, log in as the student user.
You do not need to enter any password.
[student@workstation ~]$ ssh student@servera
[student@servera ~]$Verify that the file system in the encrypted partition is mounted on the /encrypted directory.
[student@servera ~]$ mount | grep /encrypted
/dev/mapper/encryptedvdb1 on /encrypted type xfs (rw,relatime,seclabel,attr2,inode64,noquota,_netdev)Verify that the previously created file, testfile, is still available in the /encrypted directory.
When done, log out of the servera machine.
[student@servera ~]$ls /encryptedtestfile [student@servera ~]$logoutConnection to servera closed. [student@workstation ~]$
Rotate the keys for the Tang servers by running the /home/student/nbde_servers.yml playbook again.
Run the /home/student/nbde_servers.yml Ansible Playbook by using the ansible-playbook command.
Include the --ask-become-pass option to provide the student sudo password interactively.
Use the /home/student/RH415/labs/luks-nbde/inventory inventory file.
[student@workstation ~]$ ansible-playbook \
-i /home/student/RH415/labs/luks-nbde/inventory \
--ask-become-pass ~/nbde_servers.yml
...output omitted...
PLAY RECAP ***********************************************************************************
serverb : ok=25 changed=1 unreachable=0 failed=0 skipped=30 rescued=0 ignored=0
serverc : ok=26 changed=1 unreachable=0 failed=0 skipped=29 rescued=0 ignored=0
serverd : ok=26 changed=1 unreachable=0 failed=0 skipped=29 rescued=0 ignored=0