Skip to content

phoenixnap/drive-encryption-bmc

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation


phoenixnap Bare Metal Cloud
Bare Metal Cloud Drive Encryption Using EMP

Automatically mount an encrypted drive on Bare Metal Cloud. This collection uses the phoenixNAP Encryption Management Platform (EMP) as a key storage system and PyKMIP to transfer certificates for maximum token security.

Bare Metal CloudEncryption Management PlatformDevelopers PortalKnowledge BaseSupport

Requirements

  • Bare Metal Cloud account
  • EMP account
  • Python 3 (versions 3.6 and higher)
    • Python PyKMIP package
  • Cryptsetup
sudo apt install cryptsetup-bin
  • luksFormat

Creating a Bare Metal Cloud account

  1. Go to the Bare Metal Cloud signup page.
  2. Follow the prompts to set up your account.
  3. Use your credentials to log in to Bare Metal Cloud portal.

▶️ Video tutorial: How to Create a Bare Metal Cloud Account

▶️ Video tutorial: Introduction to Bare Metal Cloud

Creating an EMP account

  1. Go to the EMP signup page.
  2. Follow the prompts to set up your account.
  3. Use your credentials to log in to EMP portal.

Pre-Setup EMP

Provision and secure tokens using the phoenixNAP EMP platform.

  1. Create Group.
  2. Add New App to the group.
  3. Copy the UUID of the App.
  4. SSH into the BMC server and provide the identity file. For example:
ssh -i .ssh/id_rsa [email protected]
  1. In the terminal, generate a private key:
openssl genrsa -out <key name>.key
  1. Generate the certificate using the key. Set the Common Name as the App UUID:
openssl req -new -x509 -key <key name>.key -out <certificate name>.cert -days <number of days>
  1. Change App authentication to Certificate and upload generated Certificate to the App.

Installing PyKMIP

  1. Update and upgrade the system:
sudo apt update && sudo apt upgrade
  1. Install pip for Python 3 with the following command:
sudo apt install python3-pip
  1. Upgrade pip:
pip3 install --upgrade pip
  1. Install the PyKMIP module by running:
sudo -H pip3 install pykmip

Security Object

Use the pykimp.conf file as a configuration template for PyKMIP and add the paths to the security objects. Run the generate_key.py script to create a security object in EMP. Copy the UUID of the security object and add it to the key.py script to fetch the key automatically.

Encrypt the Device Using LUKS and CryptSetup

  1. Create an encrypted file container using the dd command:
dd of=secretfs bs=1G count=0 seek=2
  1. Change the container permission to 600 using the chmod command:
sudo chmod 600 secretfs
  1. Attach the file container to a loop device with the losetup command:
sudo losetup /dev/loop101 secretfs
  1. Using the key.py script, format the loop device using cryptsetup and luksFormat:
python3 key.py | sudo cryptsetup -y luksFormat /dev/loop101

This command encrypts the device using LUKS encryption with the key stored in EMP.

  1. Open the encrypted file container on the loop device using the key:
python3 key.py | sudo cryptsetup luksOpen /dev/loop101 secretfs

Mount Encrypted Filesystem

  1. Format the disk using the mkfs command:
sudo mkfs.ext4 /dev/mapper/secretfs
  1. Make a mount point for the file system:
sudo mkdir /mnt/encrypted
  1. Mount the disk:
sudo mount /dev/mapper/secretfs /mnt/encrypted
  1. Check that the device mounted:
df | grep secretfs

Automount Script

Create a service in /etc/init.d with the contents of the automount file. Make the service executable, update service information and reboot. The service automatically starts on reboot. Check status with:

systemctl status automount

In case of compromise, revoke security object from EMP and the device doesn't automatically unlock and mount on the next restart. In case of connection error, the service retries to connect.

For a comprehensive tutorial, visit our KB: BMC Drive Encryption Using EMP

Bare Metal Cloud community

Become part of the Bare Metal Cloud community to get updates on new features, help us improve the platform, and engage with developers and other users.

Resources

Documentation

Contact phoenixNAP

Get in touch with us if you have questions or need help with Bare Metal Cloud.

TwitterFacebookLinkedInInstagramYouTubeEmail


phoenixnap Bare Metal Cloud