Red Hat Enterprise Linux 9 Configuring and using network file services
Red Hat Enterprise Linux 9 Configuring and using network file services
A guide to configuring and using network file services in Red Hat Enterprise Linux 9.
The text of and illustrations in this document are licensed by Red Hat under a Creative Commons
Attribution–Share Alike 3.0 Unported license ("CC-BY-SA"). An explanation of CC-BY-SA is
available at
http://creativecommons.org/licenses/by-sa/3.0/
. In accordance with CC-BY-SA, if you distribute this document or an adaptation of it, you must
provide the URL for the original version.
Red Hat, as the licensor of this document, waives the right to enforce, and agrees not to assert,
Section 4d of CC-BY-SA to the fullest extent permitted by applicable law.
Red Hat, Red Hat Enterprise Linux, the Shadowman logo, the Red Hat logo, JBoss, OpenShift,
Fedora, the Infinity logo, and RHCE are trademarks of Red Hat, Inc., registered in the United States
and other countries.
Linux ® is the registered trademark of Linus Torvalds in the United States and other countries.
XFS ® is a trademark of Silicon Graphics International Corp. or its subsidiaries in the United States
and/or other countries.
MySQL ® is a registered trademark of MySQL AB in the United States, the European Union and
other countries.
Node.js ® is an official trademark of Joyent. Red Hat is not formally related to or endorsed by the
official Joyent Node.js open source or commercial project.
The OpenStack ® Word Mark and OpenStack logo are either registered trademarks/service marks
or trademarks/service marks of the OpenStack Foundation, in the United States and other
countries and are used with the OpenStack Foundation's permission. We are not affiliated with,
endorsed or sponsored by the OpenStack Foundation, or the OpenStack community.
Abstract
This document describes how to configure and run network file services on Red Hat Enterprise
Linux 9, including Samba server and NFS server.
Table of Contents
Table of Contents
. . . . . . . . . .OPEN
MAKING . . . . . . SOURCE
. . . . . . . . . .MORE
. . . . . . .INCLUSIVE
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 5. . . . . . . . . . . . .
. . . . . . . . . . . . . FEEDBACK
PROVIDING . . . . . . . . . . . . ON
. . . .RED
. . . . .HAT
. . . . .DOCUMENTATION
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6. . . . . . . . . . . . .
.CHAPTER
. . . . . . . . . . 1.. .USING
. . . . . . . SAMBA
. . . . . . . . AS
. . . .A. .SERVER
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7. . . . . . . . . . . . .
1.1. UNDERSTANDING THE DIFFERENT SAMBA SERVICES AND MODES 7
1.1.1. The Samba services 7
1.1.2. The Samba security services 8
1.1.3. Scenarios when Samba services and Samba client utilities load and reload their configuration 8
1.1.4. Editing the Samba configuration in a safe way 9
1.2. VERIFYING THE SMB.CONF FILE BY USING THE TESTPARM UTILITY 10
1.3. SETTING UP SAMBA AS A STANDALONE SERVER 10
1.3.1. Setting up the server configuration for the standalone server 11
1.3.2. Creating and enabling local user accounts 12
1.4. UNDERSTANDING AND CONFIGURING SAMBA ID MAPPING 12
1.4.1. Planning Samba ID ranges 13
1.4.2. The * default domain 14
1.4.3. Using the tdb ID mapping back end 15
1.4.4. Using the ad ID mapping back end 15
1.4.5. Using the rid ID mapping back end 17
1.4.6. Using the autorid ID mapping back end 19
1.5. SETTING UP SAMBA AS AN AD DOMAIN MEMBER SERVER 21
1.5.1. Joining a RHEL system to an AD domain 21
1.5.2. Using the local authorization plug-in for MIT Kerberos 24
1.6. SETTING UP SAMBA ON AN IDM DOMAIN MEMBER 24
1.6.1. Preparing the IdM domain for installing Samba on domain members 25
1.6.2. Installing and configuring a Samba server on an IdM client 27
1.6.3. Manually adding an ID mapping configuration if IdM trusts a new domain 28
1.6.4. Additional resources 30
1.7. SETTING UP A SAMBA FILE SHARE THAT USES POSIX ACLS 30
1.7.1. Adding a share that uses POSIX ACLs 30
1.7.2. Setting standard Linux ACLs on a Samba share that uses POSIX ACLs 31
1.7.3. Setting extended ACLs on a Samba share that uses POSIX ACLs 32
1.8. SETTING PERMISSIONS ON A SHARE THAT USES POSIX ACLS 34
1.8.1. Configuring user and group-based share access 34
1.8.2. Configuring host-based share access 35
1.9. SETTING UP A SHARE THAT USES WINDOWS ACLS 35
1.9.1. Granting the SeDiskOperatorPrivilege privilege 36
1.9.2. Enabling Windows ACL support 36
1.9.3. Adding a share that uses Windows ACLs 37
1.9.4. Managing share permissions and file system ACLs of a share that uses Windows ACLs 38
1.10. MANAGING ACLS ON AN SMB SHARE USING SMBCACLS 38
1.10.1. Access control entries 38
1.10.2. Displaying ACLs using smbcacls 41
1.10.3. ACE mask calculation 42
1.10.4. Adding, updating, and removing an ACL using smbcacls 42
Adding an ACL 42
Updating an ACL 42
Deleting an ACL 43
1.11. ENABLING USERS TO SHARE DIRECTORIES ON A SAMBA SERVER 43
1.11.1. Enabling the user shares feature 43
1
Red Hat Enterprise Linux 9 Configuring and using network file services
2
Table of Contents
. . . . . . . . . . . 2.
CHAPTER . . DEPLOYING
. . . . . . . . . . . . . .AN
. . . NFS
. . . . . SERVER
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74
..............
2.1. KEY FEATURES OF MINOR NFSV4 VERSIONS 74
2.2. THE AUTH_SYS AUTHENTICATION METHOD 75
2.3. THE AUTH_GSS AUTHENTICATION METHOD 76
2.4. FILE PERMISSIONS ON EXPORTED FILE SYSTEMS 76
2.5. SERVICES REQUIRED ON AN NFS SERVER 76
2.6. THE /ETC/EXPORTS CONFIGURATION FILE 78
2.7. CONFIGURING AN NFSV4-ONLY SERVER 78
2.8. CONFIGURING AN NFSV3 SERVER WITH OPTIONAL NFSV4 SUPPORT 80
2.9. ENABLING QUOTA SUPPORT ON AN NFS SERVER 83
2.10. ENABLING NFS OVER RDMA ON AN NFS SERVER 84
2.11. SETTING UP AN NFS SERVER WITH KERBEROS IN A RED HAT IDENTITY MANAGEMENT DOMAIN 86
3
Red Hat Enterprise Linux 9 Configuring and using network file services
4
MAKING OPEN SOURCE MORE INCLUSIVE
5
Red Hat Enterprise Linux 9 Configuring and using network file services
4. Enter your suggestion for improvement in the Description field. Include links to the relevant
parts of the documentation.
6
CHAPTER 1. USING SAMBA AS A SERVER
A standalone server
NOTE
Red Hat supports the PDC and BDC modes only in existing installations with
Windows versions which support NT4 domains. Red Hat recommends not setting
up a new Samba NT4 domain, because Microsoft operating systems later than
Windows 7 and Windows Server 2008 R2 do not support NT4 domains.
Red Hat does not support running Samba as an AD domain controller (DC).
Independently of the installation mode, you can optionally share directories and printers. This enables
Samba to act as a file and print server.
smbd
This service provides file sharing and printing services using the SMB protocol. Additionally, the
service is responsible for resource locking and for authenticating connecting users. For
authenticating domain members, smbd requires winbindd. The smb systemd service starts and
stops the smbd daemon.
To use the smbd service, install the samba package.
nmbd
This service provides host name and IP resolution using the NetBIOS over IPv4 protocol. Additionally
to the name resolution, the nmbd service enables browsing the SMB network to locate domains,
work groups, hosts, file shares, and printers. For this, the service either reports this information
directly to the broadcasting client or forwards it to a local or master browser. The nmb systemd
service starts and stops the nmbd daemon.
Note that modern SMB networks use DNS to resolve clients and IP addresses. For Kerberos a
working DNS setup is required.
7
Red Hat Enterprise Linux 9 Configuring and using network file services
winbindd
This service provides an interface for the Name Service Switch (NSS) to use AD or NT4 domain
users and groups on the local system. This enables, for example, domain users to authenticate to
services hosted on a Samba server or to other local services. The winbind systemd service starts
and stops the winbindd daemon.
If you set up Samba as a domain member, winbindd must be started before the smbd service.
Otherwise, domain users and groups are not available to the local system..
IMPORTANT
Red Hat only supports running Samba as a server with the winbindd service to
provide domain users and groups to the local system. Due to certain limitations, such
as missing Windows access control list (ACL) support and NT LAN Manager (NTLM)
fallback, SSSD is not supported.
Additional resources
1.1.3. Scenarios when Samba services and Samba client utilities load and reload their
configuration
The following describes when Samba services and utilities load and reload their configuration:
8
CHAPTER 1. USING SAMBA AS A SERVER
On manual request, for example, when you run the smbcontrol all reload-config
command.
Samba client utilities read their configuration only when you start them.
Note that certain parameters, such as security require a restart of the smb service to take effect and a
reload is not sufficient.
Additional resources
The How configuration changes are applied section in the smb.conf(5) man page
Prerequisites
Samba is installed.
Procedure
# cp /etc/samba/smb.conf /etc/samba/samba.conf.copy
# testparm -s /etc/samba/samba.conf.copy
If testparm reports errors, fix them and run the command again.
# mv /etc/samba/samba.conf.copy /etc/samba/smb.conf
5. Wait until the Samba services automatically reload their configuration or manually reload the
configuration:
Additional resources
Scenarios when Samba services and Samba client utilities load and reload their configuration
9
Red Hat Enterprise Linux 9 Configuring and using network file services
IMPORTANT
Red Hat recommends that you verify the /etc/samba/smb.conf file by using testparm
after each modification of this file.
Prerequisites
Procedure
# testparm
Load smb config files from /etc/samba/smb.conf
rlimit_max: increasing rlimit_max (1024) to minimum Windows limit (16384)
Unknown parameter encountered: "log levell"
Processing section "[example_share]"
Loaded services file OK.
ERROR: The idmap range for the domain * (tdb) overlaps with the range of DOMAIN
(ad)!
# Global parameters
[global]
...
[example_share]
...
The previous example output reports a non-existent parameter and an incorrect ID mapping
configuration.
2. If testparm reports incorrect parameters, values, or other errors in the configuration, fix the
problem and run the utility again.
10
CHAPTER 1. USING SAMBA AS A SERVER
Procedure
[global]
workgroup = Example-WG
netbios name = Server
security = user
This configuration defines a standalone server named Server within the Example-WG work
group. Additionally, this configuration enables logging on a minimal level (1) and log files will be
stored in the /var/log/samba/ directory. Samba will expand the %m macro in the log file
parameter to the NetBIOS name of connecting clients. This enables individual log files for each
client.
# testparm
5. If you set up shares that require authentication, create the user accounts.
For details, see Creating and enabling local user accounts .
6. Open the required ports and reload the firewall configuration by using the firewall-cmd utility:
Additional resources
11
Red Hat Enterprise Linux 9 Configuring and using network file services
If you use the passdb backend = tdbsam default setting, Samba stores user accounts in the
/var/lib/samba/private/passdb.tdb database.
Prerequisites
Procedure
This command adds the example account without creating a home directory. If the account is
only used to authenticate to Samba, assign the /sbin/nologin command as shell to prevent the
account from logging in locally.
# passwd example
Enter new UNIX password: password
Retype new UNIX password: password
passwd: password updated successfully
Samba does not use the password set on the operating system account to authenticate.
However, you need to set a password to enable the account. If an account is disabled, Samba
denies access if this user connects.
3. Add the user to the Samba database and set a password to the account:
# smbpasswd -a example
New SMB password: password
Retype new SMB password: password
Added user example.
Use this password to authenticate when using this account to connect to a Samba share.
# smbpasswd -e example
Enabled user example.
12
CHAPTER 1. USING SAMBA AS A SERVER
requires unique UIDs and GIDs for each user and group. If you run Samba as a domain member, the
winbindd service is responsible for providing information about domain users and groups to the
operating system.
To enable the winbindd service to provide unique IDs for users and groups to Linux, you must configure
ID mapping in the /etc/samba/smb.conf file for:
Each trusted domain from which users must be able to access resources on this Samba server
Samba provides different ID mapping back ends for specific configurations. The most frequently used
back ends are:
ad AD domains only
WARNING
The following shows non-overlapping ID mapping ranges for the default (*), AD-DOM, and the
TRUST-DOM domains.
[global]
...
idmap config * : backend = tdb
idmap config * : range = 10000-999999
13
Red Hat Enterprise Linux 9 Configuring and using network file services
IMPORTANT
You can only assign one range per domain. Therefore, leave enough space between the
domains ranges. This enables you to extend the range later if your domain grows.
If you later assign a different range to a domain, the ownership of files and directories
previously created by these users and groups will be lost.
Each trusted domain that should be able to access the Samba server
However, for all other objects, Samba assigns IDs from the default domain. This includes:
IMPORTANT
You must configure the default domain as described to enable Samba to operate
correctly.
The default domain back end must be writable to permanently store the assigned IDs.
For the default domain, you can use one of the following back ends:
tdb
When you configure the default domain to use the tdb back end, set an ID range that is big enough
to include objects that will be created in the future and that are not part of a defined domain ID
mapping configuration.
For example, set the following in the [global] section in the /etc/samba/smb.conf file:
For further details, see Using the TDB ID mapping back end .
autorid
When you configure the default domain to use the autorid back end, adding additional ID mapping
configurations for domains is optional.
For example, set the following in the [global] section in the /etc/samba/smb.conf file:
14
CHAPTER 1. USING SAMBA AS A SERVER
For further details, see Using the autorid ID mapping back end .
Use this back end only for the * default domain. For example:
Additional resources
The ad ID mapping back end implements a read-only API to read account and group information from
AD. This provides the following benefits:
User and group IDs are consistent on all Samba servers that use this back end.
The IDs are not stored in a local database which can corrupt, and therefore file ownerships
cannot be lost.
NOTE
The ad ID mapping back end does not support Active Directory domains with one-way
trusts. If you configure a domain member in an Active Directory with one-way trusts, use
instead one of the following ID mapping back ends: tdb, rid, or autorid.
sAMAccountName User and group User or group name, depending on the object
15
Red Hat Enterprise Linux 9 Configuring and using network file services
[a] Samba only reads this attribute if you set idmap config DOMAIN:unix_nss_info = yes.
[b] Samba only reads this attribute if you set idmap config DOMAIN:unix_primary_group = yes.
Prerequisites
Both users and groups must have unique IDs set in AD, and the IDs must be within the range
configured in the /etc/samba/smb.conf file. Objects whose IDs are outside of the range will not
be available on the Samba server.
Users and groups must have all required attributes set in AD. If required attributes are missing,
the user or group will not be available on the Samba server. The required attributes depend on
your configuration. .Prerequisites
Procedure
a. Add an ID mapping configuration for the default domain (*) if it does not exist. For example:
c. Set the range of IDs that is assigned to users and groups in the AD domain. For example:
IMPORTANT
The range must not overlap with any other domain configuration on this
server. Additionally, the range must be set big enough to include all IDs
assigned in the future. For further details, see Planning Samba ID ranges.
d. Set that Samba uses the RFC 2307 schema when reading attributes from AD:
16
CHAPTER 1. USING SAMBA AS A SERVER
e. To enable Samba to read the login shell and the path to the users home directory from the
corresponding AD attribute, set:
Alternatively, you can set a uniform domain-wide home directory path and login shell that is
applied to all users. For example:
f. By default, Samba uses the primaryGroupID attribute of a user object as the user’s primary
group on Linux. Alternatively, you can configure Samba to use the value set in the
gidNumber attribute instead:
# testparm
Additional resources
Samba can use the relative identifier (RID) of a Windows SID to generate an ID on Red Hat
Enterprise Linux.
NOTE
The RID is the last part of a SID. For example, if the SID of a user is S-1-5-21-
5421822485-1151247151-421485315-30014, then 30014 is the corresponding RID.
The rid ID mapping back end implements a read-only API to calculate account and group information
based on an algorithmic mapping scheme for AD and NT4 domains. When you configure the back end,
you must set the lowest and highest RID in the idmap config DOMAIN : range parameter. Samba will
not map users or groups with a lower or higher RID than set in this parameter.
IMPORTANT
17
Red Hat Enterprise Linux 9 Configuring and using network file services
IMPORTANT
As a read-only back end, rid cannot assign new IDs, such as for BUILTIN groups.
Therefore, do not use this back end for the * default domain.
All domain users and groups that have an RID within the configured range are automatically
available on the domain member.
You do not need to manually assign IDs, home directories, and login shells.
All domain users get the same login shell and home directory assigned. However, you can use
variables.
User and group IDs are only the same across Samba domain members if all use the rid back end
with the same ID range settings.
You cannot exclude individual users or groups from being available on the domain member.
Only users and groups outside of the configured range are excluded.
Based on the formulas the winbindd service uses to calculate the IDs, duplicate IDs can occur in
multi-domain environments if objects in different domains have the same RID.
Prerequisites
Procedure
a. Add an ID mapping configuration for the default domain (*) if it does not exist. For example:
c. Set a range that is big enough to include all RIDs that will be assigned in the future. For
example:
Samba ignores users and groups whose RIDs in this domain are not within the range.
IMPORTANT
18
CHAPTER 1. USING SAMBA AS A SERVER
IMPORTANT
The range must not overlap with any other domain configuration on this
server. Additionally, the range must be set big enough to include all IDs
assigned in the future. For further details, see Planning Samba ID ranges.
d. Set a shell and home directory path that will be assigned to all mapped users. For example:
# testparm
Additional resources
Calculation of the local ID from a RID, see the idmap_rid(8) man page
The autorid back end works similar to the rid ID mapping back end, but can automatically assign IDs for
different domains. This enables you to use the autorid back end in the following situations:
For the * default domain and additional domains, without the need to create ID mapping
configurations for each of the additional domains
NOTE
If you use autorid for the default domain, adding additional ID mapping configuration for
domains is optional.
Parts of this section were adopted from the idmap config autorid documentation published in the
Samba Wiki. License: CC BY 4.0. Authors and contributors: See the history tab on the Wiki page.
All domain users and groups whose calculated UID and GID is within the configured range are
automatically available on the domain member.
19
Red Hat Enterprise Linux 9 Configuring and using network file services
You do not need to manually assign IDs, home directories, and login shells.
No duplicate IDs, even if multiple objects in a multi-domain environment have the same RID.
Drawbacks
User and group IDs are not the same across Samba domain members.
All domain users get the same login shell and home directory assigned. However, you can use
variables.
You cannot exclude individual users or groups from being available on the domain member.
Only users and groups whose calculated UID or GID is outside of the configured range are
excluded.
Prerequisites
Procedure
a. Enable the autorid ID mapping back end for the * default domain:
b. Set a range that is big enough to assign IDs for all existing and future objects. For example:
Samba ignores users and groups whose calculated IDs in this domain are not within the
range.
WARNING
After you set the range and Samba starts using it, you can only increase
the upper limit of the range. Any other change to the range can result in
new ID assignments, and thus in losing file ownerships.
Samba assigns this number of continuous IDs for each domain’s object until all IDs from the
range set in the idmap config * : range parameter are taken.
NOTE
20
CHAPTER 1. USING SAMBA AS A SERVER
NOTE
If you set a rangesize, you need to adapt the range accordingly. The range
needs to be a multiple of the rangesize.
d. Set a shell and home directory path that will be assigned to all mapped users. For example:
IMPORTANT
The range must not overlap with any other domain configuration on this
server. Additionally, the range must be set big enough to include all IDs
assigned in the future. For further details, see Planning Samba ID ranges.
# testparm
Additional resources
Share directories and printers hosted on the server to act as a file and print server
Procedure
21
Red Hat Enterprise Linux 9 Configuring and using network file services
Procedure
1. If your AD requires the deprecated RC4 encryption type for Kerberos authentication, enable
support for these ciphers in RHEL:
3. To share directories or printers on the domain member, install the samba package:
# mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
Adds the winbind module for user and group lookups to the /etc/nsswitch.conf file
Updates the Pluggable Authentication Module (PAM) configuration files in the /etc/pam.d/
directory
Starts the winbind service and enables the service to start when the system boots
6. Optionally, set an alternative ID mapping back end or customized ID mapping settings in the
/etc/samba/smb.conf file.
IMPORTANT
To enable Samba to query domain user and group information, the winbind
service must be running before you start smb.
2. If you installed the samba package to share directories and printers, enable and start the smb
service:
22
CHAPTER 1. USING SAMBA AS A SERVER
3. Optionally, if you are authenticating local logins to Active Directory, enable the
winbind_krb5_localauth plug-in. See Using the local authorization plug-in for MIT Kerberos .
Verification steps
3. Optionally, verify that you can use domain users and groups when you set permissions on files
and directories. For example, to set the owner of the /srv/samba/example.txt file to
AD\administrator and the group to AD\Domain Users:
# kinit [email protected]
# klist
Ticket cache: KCM:0
Default principal: [email protected]
# wbinfo --all-domains
BUILTIN
SAMBA-SERVER
AD
Additional resources
If you do not want to use the deprecated RC4 ciphers, you can enable the AES encryption type
in AD. See
23
Red Hat Enterprise Linux 9 Configuring and using network file services
For example, if the sAMAccountName attribute of an Active Directory user is set to EXAMPLE and the
user tries to log with the user name lowercase, Kerberos returns the user name in upper case. As a
consequence, the entries do not match and authentication fails.
Using the winbind_krb5_localauth plug-in, the account names are mapped correctly. Note that this
only applies to GSSAPI authentication and not for getting the initial ticket granting ticket (TGT).
Prerequisites
Red Hat Enterprise Linux authenticates log in attempts against Active Directory.
Procedure
Edit the /etc/krb5.conf file and add the following section:
[plugins]
localauth = {
module = winbind:/usr/lib64/samba/krb5/winbind_krb5_localauth.so
enable_only = winbind
}
Additional resources
IMPORTANT
24
CHAPTER 1. USING SAMBA AS A SERVER
IMPORTANT
If users from AD domains need to access shares and printer services provided by Samba, ensure the AES
encryption type is enabled is AD. For more information, see Enabling the AES encryption type in Active
Directory using a GPO.
Prerequisites
Both the IdM servers and the client must run on RHEL 9.0 or later.
1.6.1. Preparing the IdM domain for installing Samba on domain members
Before you can set up Samba on an IdM client, you must prepare the IdM domain using the ipa-adtrust-
install utility on an IdM server.
NOTE
Any system where you run the ipa-adtrust-install command automatically becomes an
AD trust controller. However, you must run ipa-adtrust-install only once on an IdM
server.
Prerequisites
You need root privileges to install packages and restart IdM services.
Procedure
The DNS service records are created automatically if IdM was installed with an integrated DNS
25
Red Hat Enterprise Linux 9 Configuring and using network file services
The DNS service records are created automatically if IdM was installed with an integrated DNS
server.
If you installed IdM without an integrated DNS server, ipa-adtrust-install prints a list of service
records that you must manually add to DNS before you can continue.
4. The script prompts you that the /etc/samba/smb.conf already exists and will be rewritten:
WARNING: The smb.conf already exists. Running ipa-adtrust-install will break your existing
Samba configuration.
5. The script prompts you to configure the slapi-nis plug-in, a compatibility plug-in that allows
older Linux clients to work with trusted users:
Do you want to enable support for trusted domains in Schema Compatibility plugin?
This will allow clients older than SSSD 1.9 and non-Linux clients to work with trusted users.
6. When prompted, enter the NetBIOS name for the IdM domain or press Enter to accept the
name suggested:
7. You are prompted to run the SID generation task to create a SID for any existing users:
This is a resource-intensive task, so if you have a high number of users, you can run this at
another time.
8. (Optional) By default, the Dynamic RPC port range is defined as 49152-65535 for Windows
Server 2008 and later. If you need to define a different Dynamic RPC port range for your
environment, configure Samba to use different ports and open those ports in your firewall
settings. The following example sets the port range to 55000-65000.
[root@ipaserver ~]# net conf setparm global 'rpc server dynamic port range' 55000-
65000
[root@ipaserver ~]# firewall-cmd --add-port=55000-65000/tcp
[root@ipaserver ~]# firewall-cmd --runtime-to-permanent
10. Use the smbclient utility to verify that Samba responds to Kerberos authentication from the
IdM side:
26
CHAPTER 1. USING SAMBA AS A SERVER
Prerequisites
Both the IdM servers and the client must run on RHEL 9.0 or later.
The IdM domain is prepared as described in Preparing the IdM domain for installing Samba on
domain members.
If IdM has a trust configured with AD, enable the AES encryption type for Kerberos. For
example, use a group policy object (GPO) to enable the AES encryption type. For details, see
Enabling AES encryption in Active Directory using a GPO .
Procedure
2. Use the ipa-client-samba utility to prepare the client and create an initial Samba configuration:
[root@idm_client]# ipa-client-samba
Searching for IPA server...
IPA server: DNS discovery
Chosen IPA master: idm_server.idm.example.com
SMB principal to be created: cifs/[email protected]
NetBIOS name to be used: IDM_CLIENT
Discovered domains to use:
27
Red Hat Enterprise Linux 9 Configuring and using network file services
/etc/samba/smb.conf file that dynamically shares a user’s home directory when the user
connects. If users do not have home directories on this server, or if you do not want to share
them, remove the following lines from /etc/samba/smb.conf:
[homes]
read only = no
5. Open the ports required for a Samba client in the local firewall:
Verification steps
Run the following verification step on a different IdM domain member that has the samba-client
package installed:
Additional resources
Prerequisites
You configured Samba on an IdM client. Afterward, a new trust was added to IdM.
The DES and RC4 encryption types for Kerberos must be disabled in the trusted AD domain.
28
CHAPTER 1. USING SAMBA AS A SERVER
The DES and RC4 encryption types for Kerberos must be disabled in the trusted AD domain.
For security reasons, RHEL 9 does not support these weak encryption types.
Procedure
[root@idm_client]# kinit -k
2. Use the ipa idrange-find command to display both the base ID and the ID range size of the new
domain. For example, the following command displays the values for the ad.example.com
domain:
You need the values from the ipabaseid and ipaidrangesize attributes in the next steps.
With the values from the previous step, the highest usable ID for the ad.example.com domain is
1918599999 (1918400000 + 200000 - 1).
4. Edit the /etc/samba/smb.conf file, and add the ID mapping configuration for the domain to the
[global] section:
Specify the value from ipabaseid attribute as the lowest and the computed value from the
previous step as the highest value of the range.
Verification steps
29
Red Hat Enterprise Linux 9 Configuring and using network file services
NOTE
If you need to use fine-granular Windows ACLs instead, see Setting up a share that uses
Windows ACLs.
Parts of this section were adopted from the Setting up a Share Using POSIX ACLs documentation
published in the Samba Wiki. License: CC BY 4.0. Authors and contributors: See the history tab on the
Wiki page.
Prerequisites
Samba has been set up in one of the following modes:
Standalone server
Domain member
Procedure
# mkdir -p /srv/samba/example/
2. If you run SELinux in enforcing mode, set the samba_share_t context on the directory:
30
CHAPTER 1. USING SAMBA AS A SERVER
4. Add the example share to the /etc/samba/smb.conf file. For example, to add the share write-
enabled:
[example]
path = /srv/samba/example/
read only = no
NOTE
Regardless of the file system ACLs; if you do not set read only = no, Samba
shares the directory in read-only mode.
# testparm
6. Open the required ports and reload the firewall configuration using the firewall-cmd utility:
1.7.2. Setting standard Linux ACLs on a Samba share that uses POSIX ACLs
The standard ACLs on Linux support setting permissions for one owner, one group, and for all other
undefined users. You can use the chown, chgrp, and chmod utility to update the ACLs. If you require
precise control, then you use the more complex POSIX ACLs, see
The following procedure sets the owner of the /srv/samba/example/ directory to the root user, grants
read and write permissions to the Domain Users group, and denies access to all other users.
Prerequisites
The Samba share on which you want to set the ACLs exists.
Procedure
NOTE
31
Red Hat Enterprise Linux 9 Configuring and using network file services
NOTE
Enabling the set-group-ID (SGID) bit on a directory automatically sets the default group
for all new files and subdirectories to that of the directory group, instead of the usual
behavior of setting it to the primary group of the user who created the new directory
entry.
Additional resources
1.7.3. Setting extended ACLs on a Samba share that uses POSIX ACLs
If the file system the shared directory is stored on supports extended ACLs, you can use them to set
complex permissions. Extended ACLs can contain permissions for multiple users and groups.
Extended POSIX ACLs enable you to configure complex ACLs with multiple users and groups. However,
you can only set the following permissions:
No access
Read access
Write access
Full control
If you require the fine-granular Windows permissions, such as Create folder / append data, configure
the share to use Windows ACLs.
The following procedure shows how to enable extended ACLs on a share. Additionally, it contains an
example about setting extended ACLs.
Prerequisites
The Samba share on which you want to set the ACLs exists.
Procedure
1. Enable the following parameter in the share’s section in the /etc/samba/smb.conf file to enable
ACL inheritance of extended ACLs:
For details, see the parameter description in the smb.conf(5) man page.
The following procedure sets read, write, and execute permissions for the Domain Admins
32
CHAPTER 1. USING SAMBA AS A SERVER
The following procedure sets read, write, and execute permissions for the Domain Admins
group, read, and execute permissions for the Domain Users group, and deny access to
everyone else on the /srv/samba/example/ directory:
The primary group of the directory is additionally mapped to the dynamic CREATOR
GROUP principal. When you use extended POSIX ACLs on a Samba share, this principal
is automatically added and you cannot remove it.
a. Grant read, write, and execute permissions to the Domain Admins group:
c. Set permissions for the other ACL entry to deny access to users that do not match
the other ACL entries:
These settings apply only to this directory. In Windows, these ACLs are mapped to the
This folder only mode.
3. To enable the permissions set in the previous step to be inherited by new file system
objects created in this directory:
With these settings, the This folder only mode for the principals is now set to This
folder, subfolders, and files.
Samba maps the permissions set in the procedure to the following Windows ACLs:
Domain\Domain Users Read & execute This folder, subfolders, and files
33
Red Hat Enterprise Linux 9 Configuring and using network file services
CREATOR OWNER [d] [e] Full control Subfolders and files only
[a] Samba maps the permissions for this principal from the other ACL entry.
[c] Samba maps the primary group of the directory to this entry.
[d] On new file system objects, the creator inherits automatically the permissions of this principal.
[e] Configuring or removing these principals from the ACLs not supported on shares that use POSIX ACLs.
[f] On new file system objects, the creator’s primary group inherits automatically the permissions of this
principal.
NOTE
Share-based permissions manage if a user, group, or host is able to access a share. These
settings do not affect file system ACLs.
Use share-based settings to restrict access to shares, for example, to deny access from specific hosts.
Prerequisites
Prerequisites
The Samba share on which you want to set user or group-based access exists.
Procedure
1. For example, to enable all members of the Domain Users group to access a share while access
34
CHAPTER 1. USING SAMBA AS A SERVER
1. For example, to enable all members of the Domain Users group to access a share while access
is denied for the user account, add the following parameters to the share’s configuration:
The invalid users parameter has a higher priority than the valid users parameter. For example,
if the user account is a member of the Domain Users group, access is denied to this account
when you use the previous example.
Additional resources
The following procedure explains how to enable the 127.0.0.1 IP address, the 192.0.2.0/24 IP range, and
the client1.example.com host to access a share, and additionally deny access for the
client2.example.com host:
Prerequisites
The Samba share on which you want to set host-based access exists.
Procedure
1. Add the following parameters to the configuration of the share in the /etc/samba/smb.conf file:
The hosts deny parameter has a higher priority than hosts allow. For example, if
client1.example.com resolves to an IP address that is listed in the hosts allow parameter,
access for this host is denied.
Additional resources
35
Red Hat Enterprise Linux 9 Configuring and using network file services
For details, see Setting up a Samba file share that uses POSIX ACLs .
Parts of this section were adopted from the Setting up a Share Using Windows ACLs documentation
published in the Samba Wiki. License: CC BY 4.0. Authors and contributors: See the history tab on the
Wiki page.
Procedure
NOTE
Prerequisites
Procedure
1. To enable it globally for all shares, add the following settings to the [global] section of the
/etc/samba/smb.conf file:
36
CHAPTER 1. USING SAMBA AS A SERVER
Alternatively, you can enable Windows ACL support for individual shares, by adding the same
parameters to a share’s section instead.
Procedure
# mkdir -p /srv/samba/example/
2. If you run SELinux in enforcing mode, set the samba_share_t context on the directory:
3. Add the example share to the /etc/samba/smb.conf file. For example, to add the share write-
enabled:
[example]
path = /srv/samba/example/
read only = no
NOTE
Regardless of the file system ACLs; if you do not set read only = no, Samba
shares the directory in read-only mode.
4. If you have not enabled Windows ACL support in the [global] section for all shares, add the
following parameters to the [example] section to enable this feature for this share:
# testparm
6. Open the required ports and reload the firewall configuration using the firewall-cmd utility:
37
Red Hat Enterprise Linux 9 Configuring and using network file services
1.9.4. Managing share permissions and file system ACLs of a share that uses
Windows ACLs
To manage share permissions and file system ACLs on a Samba share that uses Windows ACLs, use a
Windows applications, such as Computer Management. For details, see the Windows documentation.
Alternatively, use the smbcacls utility to manage ACLs.
NOTE
To modify the file system permissions from Windows, you must use an account that has
the SeDiskOperatorPrivilege privilege granted.
Additional resources
On a local or remote Samba server that uses advanced Windows ACLs or POSIX ACLs
On Red Hat Enterprise Linux to remotely manage ACLs on a share hosted on Windows
security_principal:access_right/inheritance_information/permissions
If the AD\Domain Users group has Modify permissions that apply to This folder, subfolders, and
files on Windows, the ACL contains the following ACE:
AD\Domain Users:ALLOWED/OI|CI/CHANGE
Security principal
The security principal is the user, group, or SID the permissions in the ACL are applied to.
38
CHAPTER 1. USING SAMBA AS A SERVER
Access right
Defines if access to an object is granted or denied. The value can be ALLOWED or DENIED.
Inheritance information
The following values exist:
IO Inherit Only The ACE does not apply to the current file or directory
Permissions
This value can be either a hex value that represents one or more Windows permissions or an
smbcacls alias:
Table 1.3. Windows permissions and their corresponding smbcacls value in hex format
39
Red Hat Enterprise Linux 9 Configuring and using network file services
Delete 0x00110000
Multiple permissions can be combined as a single hex value using the bit-wise OR operation.
Table 1.4. Existing smbcacls aliases and their corresponding Windows permission
R Read
40
CHAPTER 1. USING SAMBA AS A SERVER
W Special:
Write attributes
Read permissions
D Delete
P Change permissions
O Take ownership
X Traverse / execute
CHANGE Modify
NOTE
You can combine single-letter aliases when you set permissions. For example,
you can set RD to apply the Windows permission Read and Delete. However, you
can neither combine multiple non-single-letter aliases nor combine aliases and
hex values.
Procedure
For example, to list the ACLs of the root directory of the //server/example share:
41
Red Hat Enterprise Linux 9 Configuring and using network file services
However, if you want to set advanced Windows permissions as listed in Windows permissions and their
corresponding smbcacls value in hex format, you must use the bit-wise OR operation to calculate the
correct value. You can use the following shell command to calculate the value:
Adding an ACL
To add an ACL to the root of the //server/example share that grants CHANGE permissions for This
folder, subfolders, and files to the AD\Domain Users group:
Updating an ACL
Updating an ACL is similar to adding a new ACL. You update an ACL by overriding the ACL using the --
42
CHAPTER 1. USING SAMBA AS A SERVER
Updating an ACL is similar to adding a new ACL. You update an ACL by overriding the ACL using the --
modify parameter with an existing security principal. If smbcacls finds the security principal in the ACL
list, the utility updates the permissions. Otherwise the command fails with an error:
For example, to update the permissions of the AD\Domain Users group and set them to READ for This
folder, subfolders, and files:
Deleting an ACL
To delete an ACL, pass the --delete parameter with the exact ACL to the smbcacls utility. For example:
For example, to enable only members of the local example group to create user shares.
Procedure
# groupadd example
2. Prepare the directory for Samba to store the user share definitions and set its permissions
properly. For example:
# mkdir -p /var/lib/samba/usershares/
c. Set the sticky bit to prevent users to rename or delete files stored by other users in this
directory.
3. Edit the /etc/samba/smb.conf file and add the following to the [global] section:
a. Set the path to the directory you configured to store the user share definitions. For
example:
43
Red Hat Enterprise Linux 9 Configuring and using network file services
b. Set how many user shares Samba allows to be created on this server. For example:
If you use the default of 0 for the usershare max shares parameter, user shares are
disabled.
c. Optionally, set a list of absolute directory paths. For example, to configure that Samba only
allows to share subdirectories of the /data and /srv directory to be shared, set:
For a list of further user share-related parameters you can set, see the USERSHARES section
in the smb.conf(5) man page.
# testparm
IMPORTANT
If you set ACLs when you create a user share, you must specify the comment parameter
prior to the ACLs. To set an empty comment, use an empty string in double quotes.
Note that users can only enable guest access on a user share, if the administrator set usershare allow
guests = yes in the [global] section in the /etc/samba/smb.conf file.
A user wants to share the /srv/samba/ directory on a Samba server. The share should be named
example, have no comment set, and should be accessible by guest users. Additionally, the share
permissions should be set to full access for the AD\Domain Users group and read permissions for
other users. To add this share, run as the user:
44
CHAPTER 1. USING SAMBA AS A SERVER
Prerequisites
Procedure
To list only shares created by the user who runs the command, omit the -l parameter.
2. To display only the information about specific shares, pass the share name or wild cards to the
command. For example, to display the information about shares whose name starts with share_:
Prerequisites
Procedure
45
Red Hat Enterprise Linux 9 Configuring and using network file services
...
To list only shares created by the user who runs the command, omit the -l parameter.
2. To list only specific shares, pass the share name or wild cards to the command. For example, to
list only shares whose name starts with share_:
Prerequisites
Procedure
WARNING
If you configured Samba to map the guest account to nobody, which is the default, the ACLs in the
following example:
46
CHAPTER 1. USING SAMBA AS A SERVER
Procedure
[global]
...
map to guest = Bad User
With this setting, Samba rejects login attempts that use an incorrect password unless
the user name does not exist. If the specified user name does not exist and guest
access is enabled on a share, Samba treats the connection as a guest log in.
ii. By default, Samba maps the guest account to the nobody account on Red Hat
Enterprise Linux. Alternatively, you can set a different account. For example:
[global]
...
guest account = user_name
The account set in this parameter must exist locally on the Samba server. For security
reasons, Red Hat recommends using an account that does not have a valid shell
assigned.
[example]
...
guest ok = yes
# testparm
The fruit virtual file system (VFS) Samba module provides enhanced compatibility with Apple server
47
Red Hat Enterprise Linux 9 Configuring and using network file services
The fruit virtual file system (VFS) Samba module provides enhanced compatibility with Apple server
message block (SMB) clients.
1.13.1. Optimizing the Samba configuration for providing file shares for macOS
clients
The fruit module provides enhanced compatibility of Samba with macOS clients. You can configure the
module for all shares hosted on a Samba server to optimize the file shares for macOS clients.
NOTE
Enable the fruit module globally. Clients using macOS negotiate the server message
block version 2 (SMB2) Apple (AAPL) protocol extensions when the client establishes the
first connection to the server. If the client first connects to a share without AAPL
extensions enabled, the client does not use the extensions for any share of the server.
Prerequisites
Procedure
1. Edit the /etc/samba/smb.conf file, and enable the fruit and streams_xattr VFS modules in the
[global] section:
IMPORTANT
You must enable the fruit module before enabling streams_xattr. The fruit
module uses alternate data streams (ADS). For this reason, you must also enable
the streams_xattr module.
2. Optionally, to provide macOS Time Machine support on a share, add the following setting to the
share configuration in the /etc/samba/smb.conf file:
# testparm
Additional resources
48
CHAPTER 1. USING SAMBA AS A SERVER
Prerequisites
After smbclient connected successfully to the share, the utility enters the interactive mode and shows
the following prompt:
smb: \>
Additional resources
Procedure
49
Red Hat Enterprise Linux 9 Configuring and using network file services
smb: \example\> ls
. D 0 Thu Nov 1 10:00:00 2018
.. D 0 Thu Nov 1 10:00:00 2018
example.txt N 1048576 Thu Nov 1 10:00:00 2018
The following procedure shows how to connect to an SMB share and download a file from a
subdirectory.
Procedure
Use the following command to connect to the share, change into the example directory,
download the example.txt file:
Parts of this section were adopted from the Setting up Samba as a Print Server documentation
published in the Samba Wiki. License: CC BY 4.0. Authors and contributors: See the history tab on the
Wiki page.
Prerequisites
Samba has been set up in one of the following modes:
Standalone server
Domain member
50
CHAPTER 1. USING SAMBA AS A SERVER
NOTE
Print jobs and printer operations require remote procedure calls (RPCs). By default,
Samba starts the rpcd_spoolss service on demand to manage RPCs. During the first
RPC call, or when you update the printer list in CUPS, Samba retrieves the printer
information from CUPS. This can require approximately 1 second per printer. Therefore, if
you have more than 50 printers, tune the rpcd_spoolss settings.
Prerequisites
Procedure
[printers]
comment = All Printers
path = /var/tmp/
printable = yes
create mask = 0600
IMPORTANT
b. If the CUPS server runs on a different host or port, specify the setting in the [printers]
section:
c. If you have many printers, set the number of idle seconds to a higher value than the
numbers of printers connected to CUPS. For example, if you have 100 printers, set in the
[global] section:
rpcd_spoolss:idle_seconds = 200
If this setting does not scale in your environment, also increase the number of
rpcd_spoolss workers in the [global] section:
rpcd_spoolss:num_workers = 10
51
Red Hat Enterprise Linux 9 Configuring and using network file services
# testparm
3. Open the required ports and reload the firewall configuration using the firewall-cmd utility:
After restarting the service, Samba automatically shares all printers that are configured in the
CUPS back end. If you want to manually share only specific printers, see Manually sharing
specific printers.
Verification
Prerequisites
Procedure
load printers = no
b. Add a section for each printer you want to share. For example, to share the printer named
example in the CUPS back end as Example-Printer in Samba, add the following section:
[Example-Printer]
path = /var/tmp/
printable = yes
printer name = example
You do not need individual spool directories for each printer. You can set the same spool
directory in the path parameter for the printer as you set in the [printers] section.
52
CHAPTER 1. USING SAMBA AS A SERVER
# testparm
Parts of this section were adopted from the Setting up Automatic Printer Driver Downloads for Windows
Clients documentation published in the Samba Wiki. License: CC BY 4.0. Authors and contributors: See
the history tab on the Wiki page.
Prerequisites
Package-aware drivers
Samba does not support package-aware drivers.
Some drivers require to start a setup application that installs the driver locally on a Windows
host. In certain situations, the installer extracts the individual files into the operating system’s
temporary folder during the setup runs. To use the driver files for uploading:
Ask your printer manufacturer for drivers that support uploading to a print server.
53
Red Hat Enterprise Linux 9 Configuring and using network file services
with exactly the same name for both architectures. For example, if you are uploading the 32-bit driver
named Example PostScript and the 64-bit driver named Example PostScript (v1.0), the names do not
match. Consequently, you can only assign one of the drivers to a printer and the driver will not be
available for both architectures.
Procedure
NOTE
The following procedure explains how to share the /var/lib/samba/drivers/ directory as print$, and
enable members of the local printadmin group to upload printer drivers.
Procedure
[print$]
path = /var/lib/samba/drivers/
read only = no
write list = @printadmin
54
CHAPTER 1. USING SAMBA AS A SERVER
Only members of the printadmin group can upload printer drivers to the share.
The group of new created files and directories will be set to printadmin.
2. To upload only 64-bit drivers for all printers, include this setting in the [global] section in the
/etc/samba/smb.conf file:
Without this setting, Windows only displays drivers for which you have uploaded at least the 32-
bit version.
# testparm
# groupadd printadmin
7. If you run SELinux in enforcing mode, set the samba_share_t context on the directory:
55
Red Hat Enterprise Linux 9 Configuring and using network file services
Authenticated Read & execute, List folder This folder, subfolders, and files
Users contents, Read
For details about setting ACLs on Windows, see the Windows documentation.
Additional resources
1.16.4. Creating a GPO to enable clients to trust the Samba print server
For security reasons, recent Windows operating systems prevent clients from downloading non-
package-aware printer drivers from an untrusted server. If your print server is a member in an AD, you can
create a Group Policy Object (GPO) in your domain to trust the Samba server.
Prerequisites
The Windows computer you are using to create the GPO must have the Windows Remote Server
Administration Tools (RSAT) installed. For details, see the Windows documentation.
Procedure
1. Log into a Windows computer using an account that is allowed to edit group policies, such as the
AD domain Administrator user.
3. Right-click to your AD domain and select Create a GPO in this domain, and Link it here.
4. Enter a name for the GPO, such as Legacy Printer Driver Policy and click OK. The new GPO
56
CHAPTER 1. USING SAMBA AS A SERVER
4. Enter a name for the GPO, such as Legacy Printer Driver Policy and click OK. The new GPO
will be displayed under the domain entry.
5. Right-click to the newly-created GPO and select Edit to open the Group Policy Management
Editor.
7. On the right side of the window, double-click Point and Print Restriction to edit the policy:
i. Select Users can only point and print to these servers and enter the fully-qualified
domain name (FQDN) of the Samba print server to the field next to this option.
ii. In both check boxes under Security Prompts, select Do not show warning or
elevation prompt.
57
Red Hat Enterprise Linux 9 Configuring and using network file services
b. Click OK.
8. Double-click Package Point and Print - Approved servers to edit the policy:
58
CHAPTER 1. USING SAMBA AS A SERVER
c. Close both the Show Contents and the policy’s properties window by clicking OK.
After the Windows domain members applied the group policy, printer drivers are automatically
downloaded from the Samba server when a user connects to a printer.
Additional resources
Samba as a domain member only in Active Directory (AD) or Red Hat Identity Management
(IdM) environments with Kerberos authentication that uses AES ciphers.
Samba as a file server on an Active Directory domain member. However, this requires that
clients use Kerberos to authenticate to the server.
Due to the increased security of FIPS, the following Samba features and modes do not work if FIPS
mode is enabled:
59
Red Hat Enterprise Linux 9 Configuring and using network file services
NT4-style domain members. Note that Red Hat continues supporting the primary domain
controller (PDC) functionality IdM uses in the background.
Password changes against the Samba server. You can only perform password changes using
Kerberos against an Active Directory domain controller.
The following feature is not tested in FIPS mode and, therefore, is not supported by Red Hat:
Prerequisites
Procedure
# fips-mode-setup --enable
# reboot
# testparm -s
If the command displays any errors or incompatibilities, fix them to ensure that Samba works
correctly.
Additional resources
Parts of this section were adopted from the Performance Tuning documentation published in the Samba
Wiki. License: CC BY 4.0. Authors and contributors: See the history tab on the Wiki page.
60
CHAPTER 1. USING SAMBA AS A SERVER
Prerequisites
NOTE
To always have the latest stable SMB protocol version enabled, do not set the server
max protocol parameter. If you set the parameter manually, you will need to modify the
setting with each new version of the SMB protocol, to have the latest protocol version
enabled.
The following procedure explains how to use the default value in the server max protocol parameter.
Procedure
1. Remove the server max protocol parameter from the [global] section in the
/etc/samba/smb.conf file.
1.18.2. Tuning shares with directories that contain a large number of files
Linux supports case-sensitive file names. For this reason, Samba needs to scan directories for
uppercase and lowercase file names when searching or accessing a file. You can configure a share to
create new files only in lowercase or uppercase, which improves the performance.
Prerequisites
Procedure
NOTE
Using the settings in this procedure, files with names other than in lowercase will
no longer be displayed.
61
Red Hat Enterprise Linux 9 Configuring and using network file services
preserve case = no
short preserve case = no
For details about the parameters, see their descriptions in the smb.conf(5) man page.
# testparm
After you applied these settings, the names of all newly created files on this share use lowercase.
Because of these settings, Samba no longer needs to scan the directory for uppercase and lowercase,
which improves the performance.
To use the optimized settings from the Kernel, remove the socket options parameter from the [global]
section in the /etc/samba/smb.conf.
1.19.1. Setting the minimum SMB protocol version supported by a Samba server
In Samba, the server min protocol parameter in the /etc/samba/smb.conf file defines the minimum
server message block (SMB) protocol version the Samba server supports. You can change the minimum
SMB protocol version.
NOTE
By default, Samba on RHEL 8.2 and later supports only SMB2 and newer protocol
versions. Red Hat recommends to not use the deprecated SMB1 protocol. However, if
your environment requires SMB1, you can manually set the server min protocol
parameter to NT1 to re-enable SMB1.
Prerequisites
Procedure
1. Edit the /etc/samba/smb.conf file, add the server min protocol parameter, and set the
62
CHAPTER 1. USING SAMBA AS A SERVER
1. Edit the /etc/samba/smb.conf file, add the server min protocol parameter, and set the
parameter to the minimum SMB protocol version the server should support. For example, to set
the minimum SMB protocol version to SMB3, add:
Additional resources
1.20.1. Using the net ads join and net rpc join commands
Using the join subcommand of the net utility, you can join Samba to an AD or NT4 domain. To join the
domain, you must create the /etc/samba/smb.conf file manually, and optionally update additional
configurations, such as PAM.
IMPORTANT
Red Hat recommends using the realm utility to join a domain. The realm utility
automatically updates all involved configuration files.
Procedure
[global]
workgroup = domain_name
security = ads
passdb backend = tdbsam
realm = AD_REALM
[global]
workgroup = domain_name
security = user
passdb backend = tdbsam
2. Add an ID mapping configuration for the * default domain and for the domain you want to join to
the [global] section in the /etc/samba/smb.conf file.
63
Red Hat Enterprise Linux 9 Configuring and using network file services
# testparm
To join an AD domain:
5. Append the winbind source to the passwd and group database entry in the
/etc/nsswitch.conf file:
Additional resources
64
CHAPTER 1. USING SAMBA AS A SERVER
Granting privileges
To grant a privilege to an account or group, use the net rpc rights grant command.
Revoking privileges
To revoke a privilege from an account or group, use the net rpc rights revoke command.
For example, to revoke the SePrintOperatorPrivilege privilege from the DOMAIN\printadmin group:
Listing shares
To list the shares on an SMB server, use the net rpc share list command. Optionally, pass the -S
server_name parameter to the command to list the shares of a remote server. For example:
NOTE
Shares hosted on a Samba server that have browseable = no set in their section in the
/etc/samba/smb.conf file are not displayed in the output.
Adding a share
The net rpc share add command enables you to add a share to an SMB server.
For example, to add a share named example on a remote Windows server that shares the C:\example\
directory:
NOTE
65
Red Hat Enterprise Linux 9 Configuring and using network file services
NOTE
You must omit the trailing backslash in the path when specifying a Windows directory
name.
The user specified in the -U parameter must have the SeDiskOperatorPrivilege privilege
granted on the destination server.
You must write a script that adds a share section to the /etc/samba/smb.conf file and reloads
Samba. The script must be set in the add share command parameter in the [global] section in
/etc/samba/smb.conf. For further details, see the add share command description in the
smb.conf(5) man page.
Removing a share
The net rpc share delete command enables you to remove a share from an SMB server.
For example, to remove the share named example from a remote Windows server:
The user specified in the -U parameter must have the SeDiskOperatorPrivilege privilege
granted.
You must write a script that removes the share’s section from the /etc/samba/smb.conf file
and reloads Samba. The script must be set in the delete share command parameter in the
[global] section in /etc/samba/smb.conf. For further details, see the delete share command
description in the smb.conf(5) man page.
Add users
Remove Users
NOTE
Specifying a connection method, such as ads for AD domains or rpc for NT4 domains, is
only required when you list domain user accounts. Other user-related subcommands can
auto-detect the connection method.
Pass the -U user_name parameter to the command to specify a user that is allowed to perform the
requested action.
66
CHAPTER 1. USING SAMBA AS A SERVER
2. Optionally, use the remote procedure call (RPC) shell to enable the account on the AD DC or
NT4 PDC. For example:
Prerequisites
Examples
For example, you can use the rpcclient utility to:
67
Red Hat Enterprise Linux 9 Configuring and using network file services
Perform actions using the Security Account Manager Remote (SAMR) protocol.
Example 1.9. Listing Users on an SMB Server
If you run the command against a standalone server or a domain member, it lists the users in the
local database. Running the command against an AD DC or NT4 PDC lists the domain users.
Additional resources
68
CHAPTER 1. USING SAMBA AS A SERVER
Prerequisites
Procedure
To start the application, enter:
# samba-regedit
Cursor up and cursor down: Navigate through the registry tree and the values.
Prerequisites
Procedure
Reload the configuration of the smbd, nmbd, winbindd services by sending the reload-config
message type to the all destination:
69
Red Hat Enterprise Linux 9 Configuring and using network file services
Additional resources
Prerequisites
Procedure
1. If you run the command as a user, smbpasswd changes the Samba password of the user who
run the command. For example:
2. If you run smbpasswd as the root user, you can use the utility, for example, to:
NOTE
Before you can add a user to the Samba database, you must create the
account in the local operating system. See the Adding a new user from the
command line section in the Configuring basic system settings guide.
Delete a user:
70
CHAPTER 1. USING SAMBA AS A SERVER
Additional resources
Connections per PID of each smbd daemon to the Samba server. This report includes the user
name, primary group, SMB protocol version, encryption, and signing information.
Connections per Samba share. This report includes the PID of the smbd daemon, the IP of the
connecting machine, the time stamp when the connection was established, encryption, and
signing information.
A list of locked files. The report entries include further details, such as opportunistic lock
(oplock) types
Prerequisites
Procedure
# smbstatus
Locked files:
Pid Uid DenyMode Access R/W Oplock SharePath Name Time
....--------------------------------------------------------------------------------------------------------
969 10000 DENY_WRITE 0x120089 RDONLY LEASE(RWH) /srv/samba/example file.txt Thu
Nov 1 10:00:00 2018
Additional resources
71
Red Hat Enterprise Linux 9 Configuring and using network file services
Prerequisites
Procedure
Use the following command to back up the content of the demo directory on the
//server/example/ share and store the content in the /root/example.tar archive:
Additional resources
Prerequisites
Procedure
You can use wbinfo, for example, to:
# wbinfo -u
AD\administrator
AD\guest
...
# wbinfo -g
AD\domain computers
AD\domain admins
AD\domain users
...
# wbinfo --name-to-sid="AD\administrator"
S-1-5-21-1762709870-351891212-3141221786-500 SID_USER (1)
72
CHAPTER 1. USING SAMBA AS A SERVER
Additional resources
Setting up Samba and the Clustered Trivial Database (CDTB) to share directories stored on an
GlusterFS volume
73
Red Hat Enterprise Linux 9 Configuring and using network file services
Server-side copy
Server-side copy is a capability of the NFS server to copy files on the server without transferring the
data back and forth over the network.
Sparse files
Enables files to have one or more empty spaces, or gaps, which are unallocated or uninitialized data
blocks consisting only of zeros. This enables applications to map out the location of holes in the
sparse file.
Space reservation
Clients can reserve or allocate space on the storage server before writing data. This prevents the
server from running out of space.
Labeled NFS
Enforces data access rights and enables SELinux labels between a client and a server for individual
files on an NFS file system.
Layout enhancements
Provides functionality to enable Parallel NFS (pNFS) servers to collect better performance statistics.
74
CHAPTER 2. DEPLOYING AN NFS SERVER
Attribute types
The file attribute structure includes required, recommended, and named attributes, each
serving distinct purposes. Required attributes, derived from NFSv3, are essential for
distinguishing file types, while recommended attributes, such as ACLs, provide enhanced
access control.
Multi-server namespace
Namespaces span across multiple servers, simplify file system transfers based on attributes,
support referrals, redundancy, and seamless server migration.
Mapping mechanisms ensure that NFS clients can access files with the appropriate permissions on the
server, even if the UID and GID assignments differ between systems. UIDs and GIDs are mapped
between NFS client and server by the following mechanisms:
Direct mapping
UIDs and GIDs are directly mapped by NFS servers and clients between local and remote systems.
This requires consistent UID and GID assignments across all systems participating in NFS file sharing.
For example, a user with UID 1000 on a client can only access the files on a share that a user with UID
1000 on the server has access to.
For a simplified ID management in an NFS environment, administrators often rely on centralized
services, such as LDAP or Network Information Service (NIS) to manage UID and GID mappings
across multiple systems.
NFS servers and clients can use the idmapd service to translate UIDs and GIDs between different
75
Red Hat Enterprise Linux 9 Configuring and using network file services
NFS servers and clients can use the idmapd service to translate UIDs and GIDs between different
systems for consistent identification and permission assignment.
Unlike AUTH_SYS, with the RPCSEC_GSS Kerberos mechanism, the server does not depend on the
client to correctly represent which user is accessing the file. Instead, cryptography is used to
authenticate users to the server, which prevents a malicious client from impersonating a user without
having that user’s Kerberos credentials.
In the /etc/exports file, the sec option defines one or multiple methods of Kerberos security that the
share should provide, and clients can mount the share with one of these methods. The sec option
supports the following values:
Note that the more cryptographic functionality a method provides, the lower is the performance.
Once the NFS file system is mounted by a remote host, the only protection each shared file has is its file
system permissions. If two users that share the same User ID (UID) value mount the same NFS file
system on different client systems, they can modify each other’s files.
NFS treats the root user on the client as equivalent to the root user on the server. However, by default,
the NFS server maps root to the nobody account when accessing an NFS share. The root_squash
option controls this behavior.
Additional resources
76
CHAPTER 2. DEPLOYING AN NFS SERVER
nfsd 3, 4 The NFS kernel module that services requests for shared NFS file
systems.
rpcbind 3 This process accepts port reservations from local remote procedure call
(RPC) services, makes them available or advertised, allowing
corresponding remote RPC services to access them. The rpcbind
service responds to requests and sets up connections to the specified
RPC service.
rpc.mountd 3, 4 This service processes MOUNT requests from NFSv3 clients, and
NFSv4 servers use internal functions of this service.
rpc.nfsd 3, 4 This process advertises explicit NFS versions and protocols the server
defines. It works with the kernel to meet the dynamic demands of NFS
clients, such as providing server threads each time an NFS client
connects.
lockd 3 This kernel module implements the Network Lock Manager (NLM)
protocol, which enables clients to lock files on the server. RHEL loads
the module automatically when the NFS server runs.
rpc.rquotad 3, 4 This service provides user quota information for remote users.
rpc.idmapd 4 This process provides NFSv4 client and server upcalls, which map
between NFSv4 names (strings in the form of `user@domain`) and
local user and group IDs.
nfsdcld 4 This service provides a NFSv4 client tracking daemon that prevents the
server from granting lock reclaims when other clients have taken
conflicting locks during a network partition combined with a server
reboot.
rpc.statd 3 This service provides notification to other NFSv3 clients when the local
host reboots, and to the kernel when a remote NFSv3 host reboots.
Additional resources
77
Red Hat Enterprise Linux 9 Configuring and using network file services
<export>
The directory that is being exported.
<host_or_network>
The host or network to which the export is being shared. For example, you can specify a hostname, an
IP address, or an IP network.
<options>
The options for the host or network.
Adding a space between a client and options, changes the behavior. For example, the following lines do
not have the same meaning:
/projects client.example.com(rw)
/projects client.example.com (rw)
In the first line, the server allows only client.example.com to mount the /projects directory in read-
write mode, and no other hosts can mount the share. However, due to the space between
client.example.com and (rw) in the second line, the server exports the directory to
client.example.com in read-only mode (default setting), but all other hosts can mount the share in
read-write mode.
The NFS server uses the following default settings for each exported directory:
sync The NFS server does not reply to requests before changes made by previous requests
are written to disk.
wdelay The server delays writing to the disk if it suspects another write request is pending..
root_squash Prevents that the root user on clients hasroot permissions on an exported directory.
With root_squash enabled, the NFS server maps access fromroot to the user
nobody .
If you do not have any NFSv3 clients in your network, you can configure the NFS server to support only
78
CHAPTER 2. DEPLOYING AN NFS SERVER
If you do not have any NFSv3 clients in your network, you can configure the NFS server to support only
NFSv4 or specific minor protocol versions of it. Using only NFSv4 on the server reduces the number of
ports that are open to the network.
Procedure
[nfsd]
vers3=n
b. Optional: If you require only specific NFSv4 minor versions, uncomment all vers4.
<minor_version> parameters and set them accordingly, for example:
[nfsd]
vers3=n
# vers4=y
vers4.0=n
vers4.1=n
vers4.2=y
With this configuration, the server provides only NFS version 4.2.
IMPORTANT
If you require only a specific NFSv4 minor version, set only the parameters
for the minor versions. Do not uncomment the vers4 parameter to avoid an
unpredictable activation or deactivation of minor versions. By default, the
vers4 parameter enables or disables all NFSv4 minor versions. However, this
behavior changes if you set vers4 in conjunction with other vers parameters.
# mkdir -p /nfs/projects/
These commands set write permissions for the users group on the /nfs/projects/ directory and
79
Red Hat Enterprise Linux 9 Configuring and using network file services
These commands set write permissions for the users group on the /nfs/projects/ directory and
ensure that the same group is automatically set on new entries created in this directory.
6. Add an export point to the /etc/exports file for each directory that you want to share:
This entry shares the /nfs/projects/ directory to be accessible with read and write access to
clients in the 192.0.2.0/24 and 2001:db8::/32 subnets.
Verification
On the server, verify that the server provides only the NFS versions that you have configured:
# cat /proc/fs/nfsd/versions
-3 +4 -4.0 -4.1 +4.2
# touch /mnt/file
# ls -l /mnt/
total 0
-rw-r--r--. 1 demo users 0 Jan 16 14:18 file
80
CHAPTER 2. DEPLOYING AN NFS SERVER
Procedure
2. Optional: By default, NFSv3 and NFSv4 are enabled. If you do not require NFSv4 or only specific
minor versions, uncomment all vers4.<minor_version> parameters and set them accordingly:
[nfsd]
# vers3=y
# vers4=y
vers4.0=n
vers4.1=n
vers4.2=y
With this configuration, the server provides only the NFS version 3 and 4.2.
IMPORTANT
If you require only a specific NFSv4 minor version, set only the parameters for
the minor versions. Do not uncomment the vers4 parameter to avoid an
unpredictable activation or deactivation of minor versions. By default, the vers4
parameter enables or disables all NFSv4 minor versions. However, this behavior
changes if you set vers4 in conjunction with other vers parameters.
3. By default, NFSv3 RPC services use random ports. To enable a firewall configuration, configure
fixed port numbers in the /etc/nfs.conf file:
a. In the [lockd] section, set a fixed port number for the nlockmgr RPC service, for example:
[lockd]
port=5555
With this setting, the service automatically uses this port number for both the UDP and TCP
protocol.
b. In the [statd] section, set a fixed port number for the rpc.statd service, for example:
[statd]
port=6666
With this setting, the service automatically uses this port number for both the UDP and TCP
protocol.
# mkdir -p /nfs/projects/
81
Red Hat Enterprise Linux 9 Configuring and using network file services
These commands set write permissions for the users group on the /nfs/projects/ directory and
ensure that the same group is automatically set on new entries created in this directory.
6. Add an export point to the /etc/exports file for each directory that you want to share:
This entry shares the /nfs/projects/ directory to be accessible with read and write access to
clients in the 192.0.2.0/24 and 2001:db8::/32 subnets.
Verification
On the server, verify that the server provides only the NFS versions that you have configured:
# cat /proc/fs/nfsd/versions
+3 +4 -4.0 -4.1 +4.2
3. Verify that the share was mounted with the specified NFS version:
# touch /mnt/file
82
CHAPTER 2. DEPLOYING AN NFS SERVER
# ls -l /mnt/
total 0
-rw-r--r--. 1 demo users 0 Jan 16 14:18 file
Prerequisites
Procedure
1. Verify that quotas are enabled on the directories that you export:
# quotaon -p /nfs/projects/
group quota on /nfs/projects (/dev/sdb1) is on
user quota on /nfs/projects (/dev/sdb1) is on
project quota on /nfs/projects (/dev/sdb1) is off
# findmnt /nfs/projects
TARGET SOURCE FSTYPE OPTIONS
/nfs/projects /dev/sdb1 xfs
rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,usrquota,grpquota
3. Optional. By default, the quota RPC service runs on port 875. If you want to run the service on a
different port, append -p <port_number> to the RPCRQUOTADOPTS variable in the
/etc/sysconfig/rpc-rquotad file:
RPCRQUOTADOPTS="-p __<port_number>__"
4. Optional: By default, remote hosts can only read quotas. To allow clients to set quotas, append
the -S option to the RPCRQUOTADOPTS variable in the /etc/sysconfig/rpc-rquotad file:
RPCRQUOTADOPTS="-S"
83
Red Hat Enterprise Linux 9 Configuring and using network file services
Verification
1. On the client:
b. Display the quota. The command depends on the file system of the exported directory. For
example:
To display the quota of a specific user on all mounted ext file systems, enter:
# quota -u <user_name>
Disk quotas for user demo (uid 1000):
Filesystem space quota limit grace files quota limit grace
server.example.com:/nfs/projects
0K 100M 200M 0 0 0
To display the user and group quota on an XFS file system, enter:
Additional resources
Prerequisites
84
CHAPTER 2. DEPLOYING AN NFS SERVER
An InfiniBand or RDMA over Converged Ethernet (RoCE) device is installed on the server.
IP over InfiniBand (IPoIB) is configured on the server, and the InfiniBand device has an IP
address assigned.
Procedure
2. If the package was already installed, verify that the xprtrdma and svcrdma modules in the
/etc/rdma/modules/rdma.conf file are uncommented:
3. Optional. By default, NFS over RDMA uses port 20049. If you want to use a different port, set
the rdma-port setting in the [nfsd] section of the /etc/nfs.conf file:
rdma-port=_<port>_
Adjust the port numbers if you set a different port than 20049.
Verification
If you set a port number other than the default (20049), pass port=<port_number> to the
command:
c. Verify that the share was mounted with the rdma option:
85
Red Hat Enterprise Linux 9 Configuring and using network file services
Additional resources
Prerequisites
The NFS server is enrolled in a Red Hat Identity Management (IdM) domain.
Procedure
# kinit admin
3. Retrieve the nfs service principal from IdM, and store it in the /etc/krb5.keytab file:
# klist -k /etc/krb5.keytab
Keytab name: FILE:/etc/krb5.keytab
KVNO Principal
---- --------------------------------------------------------------------------
1 nfs/[email protected]
1 nfs/[email protected]
1 nfs/[email protected]
1 nfs/[email protected]
7 host/[email protected]
7 host/[email protected]
7 host/[email protected]
7 host/[email protected]
By default, the IdM client adds the host principal to the /etc/krb5.keytab file when you join the
host to the IdM domain. If the host principal is missing, use the ipa-getkeytab -s
86
CHAPTER 2. DEPLOYING AN NFS SERVER
# ipa-client-automount
Searching for IPA server...
IPA server: DNS discovery
Location: default
Continue to configure the system with these values? [no]: yes
Configured /etc/idmapd.conf
Restarting sssd, waiting for it to become available.
Started autofs
6. Update your /etc/exports file, and add the Kerberos security method to the client options. For
example:
/nfs/projects/ 192.0.2.0/24(rw,sec=krb5i)
If you want that your clients can select from multiple security methods, specify them separated
by colons:
/nfs/projects/ 192.0.2.0/24(rw,sec=krb5:krb5i:krb5p)
# exportfs -r
87