Nextcloud can connect to Windows file servers or other SMB-compatible servers with the SMB/CIFS backend.
The SMB/CIFS backend requires
the PHP smbclient module to be installed on the Nextcloud server. The PHP
smbclient module is preferred, but either will work. These
should be included in any Linux distribution. (See PECL smbclient if your distro does not include
You need the following information:
- Folder name for your local mountpoint.
- Host: The URL of the Samba server.
- Username: The username or
domain\username(see below) used to login to the Samba server.
- Password: the password to login to the Samba server.
- Share: The share on the Samba server to mount.
- Remote Subfolder: The remote subfolder inside the Samba share to mount
(optional, defaults to /). To assign the Nextcloud logon username
automatically to the subfolder, use
$userinstead of a particular subfolder name.
- And finally, the Nextcloud users and groups who get access to the share.
Optionally, you can specify a
Domain. This is useful in
cases where the
SMB server requires a domain and a username, and an advanced authentication
mechanism like session credentials is used so that the username cannot be
modified. This is concatenated with the username, so the backend gets
For improved reliability and performance, we recommended installing
libsmbclient-php, a native PHP module for connecting to
See Configuring External Storage (GUI) for additional mount options and information.
See External Storage authentication mechanisms for more information on authentication schemes.
SMB update notifications¶
Nextcloud can use smb update notifications to listen for changes made to a configured SMB/CIFS storage and detect external changes made to the storage in near real-time.
Due to limitations of linux based SMB servers, this feature only works reliably on Windows SMB servers.
Using update notifications requires
smbclient 4.x or newer.
Due to limitations with the smbclient PHP module, the
is required even when using the PHP module.
To start listening to update notifications, start the
occ command like this:
occ files_external:notify <mount_id>
You can find the mount id for a specific storage using
On default this command shows no output, can you see the list of detected changes by
-v option to the command.
Update notifications are not supported when using ‘Login credentials, save in session’ authentication. Using login credentials is only supported with ‘Login credentials, save in database’.
Even when using ‘Login credentials, save in database’ or ‘User entered, stored in database’ authentication the notify process
can not use the credentials saved to attach to the smb shares because the notify process does not run in the context of a specific user
in those cases you can provide the username and password using the
Decrease sync delay¶
Any updates detected by the notify command will only be synced to the client after the Nextcloud cron job has been executed
(usually every 15 minutes). If this interval is to high for your use case, you can decrease it by running
occ files:scan --unscanned --all
at the desired interval. Note that this might increase the server load and you’ll need to ensure that there is no overlap between runs.