Server-side Encryption

Overview

Nextcloud provides several encryption methods to protect your data. These work at different layers of the system and address different security needs. This guide focuses on Nextcloud's built-in Server-Side Encryption (SSE).

Definitions

Encryption Method Comparison

Method

Encryption Location

Who Can Decrypt?

Protects Against

SSE (Master Key)

Server

Admins & users

External storage providers

SSE (User Keys)

Server

Users & malicious admins

External storage providers

SSE (User Keys w/ Recovery)

Server

Users & admins with recovery key

External storage providers

E2EE

Client

Users only

Admins, external storage providers

Disk/Block Encryption

Server

OS admin

Physical tampering, theft

Key Points & Limitations

Before You Enable Encryption

  1. Read this guide fully and understand the risks.

  2. Back up your instance configuration and all encryption keys in a safe location before proceeding.

  3. Decide which key management mode suits your needs (see below).

Key Management Modes

Master Key (default):

User Keys:

How to choose:

To select user key mode:

Run:

occ encryption:disable-master-key

before enabling encryption.

Enabling Encryption (Step-by-Step)

  1. Go to the Server-side encryption section of your Admin page.

  2. Check Enable server-side encryption.

  3. You’ll see a message: "No encryption module loaded." Go to your Apps page and enable the Nextcloud Default Encryption Module.

  4. Return to your Admin page. The module will appear and be auto-selected.

  5. Log out and log back in to initialize your encryption keys.

  6. Optional: Un-check the box for encrypting home storage if you wish to keep local files unencrypted.

images/encryption3.png
images/encryption14.png
images/encryption15.png

Backups

Encryption keys are stored in:

Encrypting External Mountpoints and Team Folders

occ config:app:set groupfolders enable_encryption --value=true

Managing Encryption via occ Commands

Here is a reference table for common occ commands:

Command

Description

occ encryption:status

Show encryption status and module

occ encryption:enable

Enable server-side encryption

occ encryption:list-modules

List available encryption modules

occ encryption:set-default-module [Module ID]

Select default encryption module

occ encryption:encrypt-all

Encrypt all files for all users

occ encryption:decrypt-all [user]

Decrypt all files (or for one user)

occ encryption:show-key-storage-root

Show key storage location

occ encryption:change-key-storage-root [dir]

Move key storage directory

occ encryption:enable-master-key

Enable master key mode

occ encryption:disable-master-key

Disable master key mode

occ encryption:fix-encrypted-version

Fix bad signature errors

occ encryption:fix-key-location [user]

Fix key not found errors

Example: Move keys to a new directory (Ubuntu Linux):

cd /your/nextcloud/data
mkdir keys
chown -R root:www-data keys
chmod -R 0770 keys
occ encryption:change-key-storage-root keys

Encrypting All Files

By default, only new and changed files are encrypted when you enable SSE. To encrypt all files for all users run:

occ encryption:encrypt-all

Decrypting Files / Disabling Encryption

occ encryption:decrypt-all

You can decrypt for individual users:

occ encryption:decrypt-all <user-id>

Data Not Encrypted

Only file contents are encrypted. The following are not encrypted:

Not Encrypted

Filenames and folder structures

Existing trash bin files

Existing historical file versions

Image thumbnails

Image previews

Full text search index

Application data that isn't file-based (e.g., Deck, Tables)

User Keys: Sharing & Recovery

Sharing encrypted files:

images/encryption9.png

Enabling file recovery keys:

Recovery keys are only available in per-user key mode (not the default master key mode).

images/encryption10.png
images/encryption7.png
images/encryption8.png
images/encryption12.png

LDAP and External User Backends

Troubleshooting

Why don't I see the recovery key option in the Encryption settings?

Recovery keys are only available in per-user key mode. Since Nextcloud 13, the default encryption mode uses master keys (system-wide encryption). Master key mode does not expose recovery key options in the Admin settings because recovery keys are not needed—admins can reset user passwords and files remain accessible.

If you are using master key mode (the default and recommended mode), you do not need recovery keys. Recovery keys are only relevant for per-user key setups, which are maintained for compatibility with older deployments.

See :ref:`Key Management Modes <encryption_configuration_key_management_modes>` for guidance on the differences between master key and per-user key modes, and GitHub Issue #8283 for technical context on this design decision.

Invalid private key for encryption app

See GitHub Issue #8546 and workaround.

Bad signature error

In some rare cases, encrypted files cannot be downloaded and return a "500 Internal Server Error." If the Nextcloud log contains an error about "Bad Signature," run the following command to repair affected files:

occ encryption:fix-encrypted-version userId --path=/path/to/broken/file.txt

Replace "userId" and the path accordingly. The command will perform a test decryption for all files and automatically repair those with a signature error.

Encryption key cannot be found

If the logs contain an error stating that the encryption key cannot be found, you can manually search the data directory for a folder that has the same name as the file name. For example, if a file "example.md" cannot be decrypted, run:

find path/to/datadir -name example.md -type d

Then check the results located in the files_encryption folder. If the key folder is in the wrong location, move it to the correct folder and try again.

The data/files_encryption folder contains encryption keys for group folders and system-wide external storages, while data/$userid/files_encryption contains the keys for specific user storage files.

Encryption key cannot be found with external storage or group folders

To resolve this issue, run the following command:

sudo -E -u www-data php occ encryption:fix-key-location <user-id>

This will attempt to recover keys that were not moved properly.

If this doesn't resolve the problem, refer to the section :ref:`Encryption key cannot be found<troubleshooting_encryption_key_not_found>` for a manual procedure.

Further Reading