← Back to list

Encrypting Data at Rest will save you one day

Encrypting Data at Rest on Ubuntu, Windows, AWS, and Microsoft 365 — Open-Source Options, Commands, and Install Guides

Cube1214 · 2025-11-13 01:07 · 0 claps · 7.0 min read
#encrypting #data #tools #ubun #windo
Open on Medium ↗
Wiki topics: ☁️ · DevOps & Cloud 🔓 · Open Source 🥊 · Combat Sports

Encrypting Data at Rest will save you one day

Encrypting Data at Rest on Ubuntu, Windows, AWS, and Microsoft 365 — Open-Source Options, Commands, and Install Guides

Abstract

Encrypting data at rest reduces the blast radius of account compromise, device theft, and cloud-side misconfiguration. This article maps standards-based guidance (NIST and IETF) to practical, free/open-source tooling for Ubuntu and Windows endpoints, and shows how to combine client-side encryption with provider-side controls in AWS and Microsoft 365 (OneDrive/SharePoint). We include pros/cons, installation steps, and copy-pasteable command lines. Where possible, choices align with AEAD ciphers and modern KDFs recommended by NIST and the IETF. (NIST Computer Security Resource Center)

Background: what “good” looks like

NIST SP 800–111 frames when to prefer full-disk, volume, or file/folder encryption; SP 800–57 Pt.1 covers key lifecycles (generation, storage, rotation, destruction). For authenticated encryption, NIST SP 800–38D (AES-GCM) and RFC 8439 (ChaCha20-Poly1305) are the touchstones. For password-derived keys, RFC 9106 (Argon2) and RFC 7914 (scrypt) are the current standards. Tools below use these building blocks (e.g., X25519 per RFC 7748 in age). (NIST Computer Security Resource Center)

Ubuntu: open-source tools, install & commands

Tool set (3 common choices)

  • cryptsetup (LUKS/dm-crypt) — full-disk/partition encryption with multiple key slots. Best for laptops, servers, and removable media. (man7.org)
  • gocryptfs — per-file, user-space overlay (FUSE). Good for selective encryption and cloud sync folders. (GitHub)
  • restic — encrypted, deduplicated backups to local, S3, or many remotes (directly or via rclone). (Restic Documentation)

Install (Ubuntu)

sudo apt update
sudo apt install -y cryptsetup gocryptfs restic

Commands (Ubuntu)

Full-disk / partition with LUKS (DESTROYS data on the target — pick the right device!):

sudo cryptsetup luksFormat /dev/sdX
sudo cryptsetup luksOpen /dev/sdX secure_volume
sudo mkfs.ext4 /dev/mapper/secure_volume
sudo mkdir -p /mnt/secure && sudo mount /dev/mapper/secure_volume /mnt/secure
# verify & later close
sudo cryptsetup status secure_volume
sudo umount /mnt/secure && sudo cryptsetup luksClose secure_volume

LUKS2 provides multiple key slots and robust metadata; follow NIST key-management guidance for passphrases/keys. (man7.org)

Per-file overlay with gocryptfs (keeps encrypted files in ~/cipherdir):

mkdir -p ~/cipherdir ~/plain
gocryptfs -init ~/cipherdir
gocryptfs ~/cipherdir ~/plain
# put cleartext files in ~/plain; ciphertext lands in ~/cipherdir
fusermount -u ~/plain   # unmount when done

gocryptfs emphasizes integrity and filename encryption; see the manpage for options. (GitHub)

Encrypted backups with restic (example: local path repo):

export RESTIC_PASSWORD="use-a-strong-passphrase"
restic -r /mnt/secure/restic-repo init
restic -r /mnt/secure/restic-repo backup ~/Documents
restic -r /mnt/secure/restic-repo snapshots
restic -r /mnt/secure/restic-repo check

Restic encrypts and authenticates data/metadata by design; use strong, memory-hard passphrases (Argon2/scrypt guidance). (Restic Documentation)

Ubuntu pros

  • Native full-disk protection (LUKS) with well-understood threat model.
  • Per-file overlay (gocryptfs) plays nicely with cloud sync.
  • Backup encryption (restic) travels with the data across backends.

Ubuntu cons

  • LUKS protects at rest; once mounted, plaintext is accessible to processes with access.
  • FUSE overlays require mount discipline and can confuse some backup tools.
  • Key loss = data loss; plan escrow/rotation per SP 800–57. (NIST Publications)

Windows: open-source tools, install & commands

Tool set (3 common choices)

  • VeraCrypt — audited successor to TrueCrypt; volumes/containers or full-disk. (Documentation Help)
  • age — modern file encryption with small keys (great for scripts/archives). (GitHub)
  • rclone (optional pairing) — sync encrypted payloads to cloud or SFTP (use with rclone crypt or pre-encrypt with age). (Rclone)

Install (Windows, PowerShell with WinGet)

winget install --id=IDRIX.VeraCrypt -e
winget install --id=FiloSottile.age -e
winget install --id=Rclone.Rclone -e

(WinGet usage details are in Microsoft’s docs; package IDs above are commonly used.) (Microsoft Learn)

Commands (Windows)

VeraCrypt: create & mount a container (example 4 GiB, AES):

# Create 4 GiB container at D:\vault.hc (you'll be prompted)
veracrypt /create D:\vault.hc /size 4G /encryption AES /hash SHA-512 /filesystem NTFS /p
# Mount to drive letter V:
veracrypt /volume D:\vault.hc /letter V /quit /silent /p
# Dismount
veracrypt /dismount V /quit

(See official CLI syntax notes; /p prompts for a password.) (VeraCrypt)

age: generate keys, encrypt a folder tarball, decrypt later:

age-keygen -o key.txt
age-keygen -y key.txt > pubkey.txt
tar -cf data.tar "C:\Path\To\Folder"
age -r (Get-Content pubkey.txt) -o data.tar.age data.tar
age -d -i key.txt -o data_restored.tar data.tar.age

age uses modern primitives (X25519 + ChaCha20-Poly1305) aligned with current best practice. (GitHub)

rclone: upload the ciphertext (OneDrive example after rclone config):

rclone copy data.tar.age onedrive:Encrypted --progress

For transparent per-file encryption instead of tarballs, wrap your remote with rclone crypt. (Rclone)

Windows pros

  • VeraCrypt volumes work offline and are portable between hosts.
  • age is script-friendly and avoids legacy PGP complexity.
  • rclone reaches many storage targets with one CLI.

Windows cons

  • Containers require mounting; incorrect dismounting risks corruption.
  • age encrypts files, not live volumes (by design).
  • WinGet package availability may fluctuate for some third-party tools. (GitHub)

AWS: provider-side encryption + client-side defense in depth

What AWS does by default

As of January 5, 2023, Amazon S3 automatically applies server-side encryption (SSE-S3) to new objects. You can also enforce bucket-level defaults (SSE-S3 or SSE-KMS). For block storage, enable EBS encryption by default per-Region so new volumes/snapshots are always encrypted (typically with AWS-managed or your KMS CMK). (AWS Documentation)

Commands (AWS CLI)

S3: set bucket default encryption

aws s3api put-bucket-encryption --bucket MY_BUCKET \
  --server-side-encryption-configuration \
'{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"AES256"}}]}'
# or use your KMS CMK
aws s3api put-bucket-encryption --bucket MY_BUCKET \
  --server-side-encryption-configuration \
'{"Rules":[{"ApplyServerSideEncryptionByDefault":{"SSEAlgorithm":"aws:kms","KMSMasterKeyID":"arn:aws:kms:REGION:ACCT:key/KEY-ID"},"BucketKeyEnabled":true}]}'
aws s3api get-bucket-encryption --bucket MY_BUCKET

(Documentation and default-encryption notes here.) (AWS Documentation)

EBS: enable encryption by default (current Region)

aws ec2 enable-ebs-encryption-by-default
aws ec2 get-ebs-encryption-by-default
# optionally set your default KMS key
aws ec2 modify-ebs-default-kms-key-id --kms-key-id alias/aws/ebs

(AWS CLI/API references and behavior are documented.) (AWS Documentation)

Client-side (open-source) on top of AWS

For backups that stay encrypted regardless of bucket or IAM settings, restic can write directly to S3 (or via an rclone remote).

export RESTIC_PASSWORD="strong-passphrase"
restic -r s3:s3.amazonaws.com/MY_BUCKET/restic init
restic -r s3:s3.amazonaws.com/MY_BUCKET/restic backup /data
restic -r s3:s3.amazonaws.com/MY_BUCKET/restic check

This stacks AEAD encryption over SSE, separating duties and limiting risk. (Restic Documentation)

AWS pros

  • Transparent SSE for S3 and full-stack EBS encryption default.
  • KMS gives audit trails and key separation (SSE-KMS).
  • Adding restic gives end-to-end confidentiality outside AWS’ trust boundary.

AWS cons

  • SSE protects data at rest on AWS but not against account-level misuse.
  • KMS key policy/rotation adds operational complexity.
  • Client-side encryption complicates server-side processing and search. (AWS Documentation)

Microsoft 365 (OneDrive/SharePoint): service encryption + client-side hardening

What Microsoft provides

Microsoft 365 applies volume-level encryption (e.g., BitLocker) and service encryption at the application layer for OneDrive/SharePoint. Organizations can optionally bring Customer Key (Azure Key Vault) to control per-tenant keys and key rotation. These layers protect data at rest inside Microsoft’s cloud. (Microsoft Learn)

Set up Customer Key (overview + example cmdlet)

Customer Key is an extra layer on top of service encryption. After provisioning two Azure Key Vault keys in separate regions, create a Data Encryption Policy (DEP), then apply to workloads. Example (Exchange Online PowerShell shown in docs; SharePoint/OneDrive uses SharePoint PowerShell):

New-M365DataAtRestEncryptionPolicy -Name ContosoDEP `
  -AzureKeyIDs "https://vault1.vault.azure.net/keys/keyA","https://vault2.vault.azure.net/keys/keyB"

(Microsoft’s step-by-step guidance: setup, manage, and workload specifics.) (Microsoft Learn)

Client-side (open-source) for OneDrive/SharePoint

If you want end-to-end control regardless of tenant settings, encrypt before sync:

Option A: rclone crypt (transparent per-file encryption)

# After `rclone config` sets up onedrive: …
rclone config create secret crypt remote=onedrive:Encrypted
rclone copy ~/Docs secret: --progress

Option B: age pre-encryption (archive + encrypt, then upload)

age-keygen -o key.txt && age-keygen -y key.txt > pubkey.txt
tar -cf data.tar /path/to/folder
age -r "$(cat pubkey.txt)" -o data.tar.age data.tar
rclone copy data.tar.age onedrive:Encrypted --progress

rclone crypt and age are fully open source and independent of Microsoft accounts/keys. (Rclone)

Microsoft pros

  • Strong, layered at-rest encryption by default; Customer Key enables customer-managed keys.
  • Service encryption separates OS admins from tenant data.
  • Client-side encryption further reduces trust on the provider.

Microsoft cons

  • Enabling Customer Key introduces operational responsibility (key availability, rotation, and incident procedures).
  • Client-side encryption can break previews, DLP, and search features.
  • PowerShell and Azure prerequisites increase setup time. (Microsoft Learn)

Practical selection guide

  • Whole-machine protection (lost/stolen devices): LUKS on Ubuntu; VeraCrypt containers/disks on Windows. (man7.org)
  • Selective folders & cloud sync: gocryptfs or rclone crypt. (GitHub)
  • Backups (on-prem/S3/anywhere): restic. (Restic Documentation)
  • Cloud providers: Turn on SSE defaults (S3) and EBS encryption; consider Customer Key in Microsoft 365 for per-tenant control. (AWS Documentation)

Key-management essentials (brief)

  • Treat encryption keys as production-grade secrets with backup, rotation, and role separation per NIST SP 800–57.
  • Prefer AEAD modes (AES-GCM or ChaCha20-Poly1305) to detect tampering (SP 800–38D, RFC 8439).
  • For passphrases, use memory-hard KDFs (Argon2/scrypt). (NIST Publications)

References (APA 7th)

Barker, E. (2020). Recommendation for key management: Part 1 — General (NIST SP 800–57 Pt.1 Rev.5). National Institute of Standards and Technology. https://doi.org/10.6028/NIST.SP.800-57pt1r5 (NIST Publications)

Biryukov, A., Dinu, D., Khovratovich, D., & Josefsson, S. (2021). Argon2 memory-hard function for password hashing and proof-of-work applications (RFC 9106). RFC Editor. https://doi.org/10.17487/RFC9106 (RFC Editor)

Dworkin, M. (2007). Recommendation for block cipher modes of operation: Galois/Counter Mode (GCM) and GMAC (NIST SP 800–38D). National Institute of Standards and Technology. https://doi.org/10.6028/NIST.SP.800-38D (NIST Computer Security Resource Center)

Langley, A., Hamburg, M., & Turner, S. (2016). Elliptic curves for security (RFC 7748). RFC Editor. https://doi.org/10.17487/RFC7748 (RFC Editor)

McGrew, D. (2008). An interface and algorithms for authenticated encryption (RFC 5116). RFC Editor. https://doi.org/10.17487/RFC5116

Nir, Y., & Langley, A. (2018). ChaCha20 and Poly1305 for IETF protocols (RFC 8439). RFC Editor. https://doi.org/10.17487/RFC8439 (RFC Editor)

Scarfone, K., Souppaya, M., & Sexton, M. (2007). Guide to storage encryption technologies for end user devices (NIST SP 800–111). National Institute of Standards and Technology. https://csrc.nist.gov/pubs/sp/800/111/final (NIST Computer Security Resource Center)

Tool & vendor documentation

Amazon Web Services. (n.d.). Using server-side encryption with Amazon S3 managed keys (SSE-S3). https://docs.aws.amazon.com/AmazonS3/latest/userguide/UsingServerSideEncryption.html (AWS Documentation)

Amazon Web Services. (n.d.). Configuring default bucket encryption. https://docs.aws.amazon.com/AmazonS3/latest/userguide/default-bucket-encryption.html (AWS Documentation)

Amazon Web Services. (n.d.). Enable Amazon EBS encryption by default. https://docs.aws.amazon.com/ebs/latest/userguide/encryption-by-default.html (AWS Documentation)

Amazon Web Services. (n.d.). enable-ebs-encryption-by-default — AWS CLI Command Reference. https://docs.aws.amazon.com/cli/latest/reference/ec2/enable-ebs-encryption-by-default.html (AWS Documentation)

Filo Sottile. (n.d.). age: A simple, modern and secure encryption tool. GitHub. https://github.com/FiloSottile/age (GitHub)

rclone contributors. (n.d.). Crypt backend. https://rclone.org/crypt/ (Rclone)

restic contributors. (n.d.). Encryption design. https://restic.readthedocs.io/en/latest/070_encryption.html (Restic Documentation)

rfjakob. (n.d.). gocryptfs manpage. GitHub. https://github.com/rfjakob/gocryptfs/blob/master/Documentation/MANPAGE.md (GitHub)

Rubini, M., & contributors. (n.d.). cryptsetup (8). man7.org. https://www.man7.org/linux/man-pages/man8/cryptsetup.8.html (man7.org)

VeraCrypt Project. (n.d.). Command line usage. https://veracrypt.io/en/Command%20Line%20Usage.html (VeraCrypt)

Microsoft. (2025). Data encryption in OneDrive and SharePoint. Microsoft Learn. https://learn.microsoft.com/en-us/purview/data-encryption-in-odb-and-spo (Microsoft Learn)

Microsoft. (2025). Service encryption and key management. Microsoft Learn. https://learn.microsoft.com/en-us/purview/microsoft-365-service-encryption (Microsoft Learn)

Microsoft. (2025). Overview of Customer Key. Microsoft Learn. https://learn.microsoft.com/en-us/purview/customer-key-overview (Microsoft Learn)

Microsoft. (2025). Set up Customer Key. Microsoft Learn. https://learn.microsoft.com/en-us/purview/customer-key-set-up (Microsoft Learn)

Microsoft. (2025). Manage Customer Key. Microsoft Learn. https://learn.microsoft.com/en-us/purview/customer-key-manage (Microsoft Learn)


메타데이터
post_id
16de25d7f3c7
slug
encrypting-data-at-rest-will-save-you-one-day-16de25d7f3c7
url
https://medium.com/@cube1214/encrypting-data-at-rest-will-save-you-one-day-16de25d7f3c7
canonical_url
https://medium.com/@cube1214/encrypting-data-at-rest-will-save-you-one-day-16de25d7f3c7
author_url
https://medium.com/@cube1214
status
ok
fetched_at
2026-06-26 21:52:29