Skip to content

Commit 48828f5

Browse files
committed
docs: add file permissions guidance to hardening page
Adds a new 'Set strong file permissions' subsection to the Deployment section of harden_server.rst. The permissions section was removed in PR #431 because the web updater needs write access to the install dir, but no replacement guidance was added. This restores the guidance with the tradeoff clearly documented: - baseline chmod/chown commands for read-only install dir - note that data/ and apps/ must stay writable - note that web updater must be disabled (upgrade.disable-web) before applying stricter install-dir permissions Fixes #1353 Signed-off-by: skjnldsv <skjnldsv@protonmail.com>
1 parent e8705ef commit 48828f5

1 file changed

Lines changed: 41 additions & 0 deletions

File tree

admin_manual/installation/harden_server.rst

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,47 @@ installation.
7474
.. You may also move your data directory on an existing
7575
.. installation; see :doc:``
7676
77+
Set strong file permissions
78+
^^^^^^^^^^^^^^^^^^^^^^^^^^^
79+
80+
Strong file system permissions reduce the attack surface if an attacker gains
81+
access to the web server process. The recommended baseline sets the Nextcloud
82+
installation directory to read-only for the web server user:
83+
84+
.. code-block:: bash
85+
86+
# Set ownership: root owns the files, web server group can read
87+
sudo chown -R root:www-data /var/www/nextcloud/
88+
89+
# Files: owner read/write, group read-only, no world access
90+
sudo find /var/www/nextcloud/ -type f -print0 | sudo xargs -0 chmod 0640
91+
92+
# Directories: owner full, group read+execute, no world access
93+
sudo find /var/www/nextcloud/ -type d -print0 | sudo xargs -0 chmod 0750
94+
95+
The **data directory** must remain writable by the web server user:
96+
97+
.. code-block:: bash
98+
99+
sudo chown -R www-data:www-data /path/to/nextcloud-data/
100+
101+
If you install or update apps via the Nextcloud **app store**, the ``apps/``
102+
directory also needs to be writable by the web server:
103+
104+
.. code-block:: bash
105+
106+
sudo chown -R www-data:www-data /var/www/nextcloud/apps/
107+
108+
.. note::
109+
110+
The built-in **web updater** requires write access to the entire Nextcloud
111+
installation directory. If you apply the read-only permissions above,
112+
the web updater will fail. Disable it first by adding the following to
113+
``config/config.php``, then use the command-line updater or package
114+
manager instead::
115+
116+
'upgrade.disable-web' => true,
117+
77118
Disable preview image generation
78119
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
79120

0 commit comments

Comments
 (0)