Back to articles
Security & Anti-DDoS

Guide to Securing Databases on VPS with Automatic Encryption at Rest

Securing databases on VPS is essential to protect sensitive information from external and internal threats. Automatic Encryption at Rest ensures that all stored data is encrypted on...

DPTCloud Engineering6 min read
Guide to Securing Databases on VPS with Automatic Encryption at Rest

Image credit: stevepb · Pixabay Content License

Securing databases on VPS is essential to protect sensitive information from external and internal threats. Automatic Encryption at Rest ensures that all stored data is encrypted on disk, even if the server is compromised or physical hardware is stolen. This guide details how to implement automatic Encryption at Rest on VPS using common tools and configurations, ensuring database data remains protected when not in use.

Introduction to Encryption at Rest

Encryption at Rest is the process of encrypting data when it is stored on a storage device, such as a hard drive or SSD. Unlike in-transit encryption, which protects data during transmission, encryption at rest ensures that data cannot be read if accessed improperly when inactive. On VPS, deploying automatic Encryption at Rest protects database data from risks such as server loss, leaked backups, or unauthorized access to storage systems.

The most common method for implementing Encryption at Rest is using LUKS (Linux Unified Key Setup) with dm-crypt on Linux operating systems. LUKS provides a robust encryption layer, supports secure key management, and enables full disk or partition encryption. With proper configuration, data is automatically encrypted during system boot and decrypted when needed, without interrupting application operations.

Requirements and Preparation

To deploy automatic Encryption at Rest on a VPS, ensure the following prerequisites are met:

  • VPS provider supports hardware and Linux operating systems (Ubuntu, CentOS, or Debian).
  • System partition is set up to support full disk or data partition encryption.
  • Encryption keys are securely stored, preferably using software keys protected by passwords or hardware keys (such as TPM).
  • Necessary software: cryptsetup, lvm2 (if using LVM), and key management tools.

At DPTCloud, you can leverage Cloud VPS with L3/L4/L7 Anycast Anti-DDoS and Network Security & 99.98% SLA Infrastructure at DPTCloud to ensure a secure foundation that supports encryption and other security solutions.

Deploying Automatic Encryption at Rest

Follow these steps to deploy automatic Encryption at Rest:

  1. Initialize the encryption partition using the command cryptsetup luksFormat /dev/sda1, then enter a strong password.
  2. Create the encrypted device with cryptsetup luksOpen /dev/sda1 encrypted_data.
  3. Format the encrypted device with a filesystem, for example: mkfs.ext4 /dev/mapper/encrypted_data.
  4. Mount the filesystem to the desired directory, such as mount /dev/mapper/encrypted_data /mnt/data.
  5. Configure automatic unlocking at boot by adding the following line to /etc/crypttab:
    encrypted_data /dev/sda1 none luks
  6. Add an entry to /etc/fstab to automatically mount the encrypted partition:
    /dev/mapper/encrypted_data /mnt/data ext4 defaults 0 2
  7. Reboot the system and verify that the partition is automatically unlocked and mounted.

To ensure the encryption process is secure and automatic, use software keys protected by passwords, or integrate with key management systems like Hashicorp Vault or Keybase. Backing up encryption keys is critical—losing the key renders data unrecoverable.

Testing and Verification

After deployment, perform the following checks to verify encryption is working correctly:

  • Run lsblk to confirm the encrypted partition is recognized.
  • Use cryptsetup status encrypted_data to check the encryption device status.
  • Ensure data written to the encrypted partition cannot be read without the key.
  • Reboot the system and confirm the partition unlocks and mounts automatically.

For systems using Docker or containers, verify that data stored in container volumes is also encrypted. Solutions such as advanced Docker security with rootless mode and Docker hardening according to CIS Benchmark can enhance overall system protection.

Alternative Solutions and Maintenance

Besides LUKS, other solutions such as dm-crypt with OpenBSD-style key management or automated storage encryption services like DPTCloud’s built-in storage encryption may be considered. However, these often require specialized infrastructure or platform-specific integration.

For maintenance, follow these practices:

  • Change encryption keys periodically.
  • Back up encryption keys to secure, distributed locations.
  • Monitor for unauthorized unlock attempts or access events.
  • Apply operating system and encryption software updates promptly to prevent security vulnerabilities.

Implementing automatic Encryption at Rest is a crucial step in a comprehensive VPS security strategy. Combined with other security measures such as Zero Trust security and container security with Kata Containers, you can build a secure, resilient, and modern VPS environment.

DPTCloud Tier III Infrastructure

Recommended NVMe Cloud VPS Plans to Deploy This Setup

Enterprise RAID 10 NVMe SSDs, CMC & FPT District 9 uplinks with Anycast Anti-DDoS and 99.99% SLA.

View 22 VPS Plans
ECO · vn-02

VPS-2E

94.600 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 2 GB
  • SSD: 30 GB NVMe
ECO · vn-02Recommended

VPS-3E

170.500 ₫ / mo

10% VAT included

  • CPU: 2 vCPU
  • RAM: 4 GB
  • SSD: 50 GB NVMe
BASIC · vn-01Recommended

VPS-05

457.600 ₫ / mo

10% VAT included

  • CPU: 4 vCPU
  • RAM: 8 GB
  • SSD: 50 GB NVMe

Related Articles

View all
ZaloZalo SupportDiscord0384 753 478