Configuring and using network file services
A guide to configuring and using network file services in Red Hat Enterprise Linux 10
Abstract
Providing feedback on Red Hat documentation Copy linkLink copied to clipboard!
We are committed to providing high-quality documentation and value your feedback. To help us improve, you can submit suggestions or report errors through the Red Hat Jira tracking system.
Procedure
Log in to the Jira website.
If you do not have an account, select the option to create one.
- Click Create in the top navigation bar.
- Enter a descriptive title in the Summary field.
- Enter your suggestion for improvement in the Description field. Include links to the relevant parts of the documentation.
- Click Create at the bottom of the dialogue.
Chapter 1. Using Samba as a server Copy linkLink copied to clipboard!
Samba implements the Server Message Block (SMB) protocol in Red Hat Enterprise Linux. The SMB protocol is used to access resources on a server, such as file shares and shared printers. Additionally, Samba implements the Distributed Computing Environment Remote Procedure Call (DCE RPC) protocol used by Microsoft Windows.
For more information refer to the:
-
smb.conf(5)man page on your system -
/usr/share/docs/samba-version/directory that contains general documentation, example scripts, and LDAP schema files, provided by the Samba project
You can run Samba as:
- An Active Directory (AD) or NT4 domain member
- A standalone server
An NT4 Primary Domain Controller (PDC) or Backup Domain Controller (BDC)
NoteRed 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.
1.1. Understanding the different Samba services and modes Copy linkLink copied to clipboard!
The samba package provides multiple services. Depending on your environment and the scenario you want to configure, you require one or more of these services and configure Samba in different modes.
1.1.1. The Samba services Copy linkLink copied to clipboard!
Samba services in Linux include smbd, nmbd, winbindd, and samba-bgqd. Understand their roles in file and printer sharing, name resolution, domain integration, and printer management.
Samba provides the following services:
smbdThis 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,
smbdrequireswinbindd. Thesmbsystemdservice starts and stops thesmbddaemon.To use the
smbdservice, install thesambapackage.nmbdThis service provides host name and IP resolution using the NetBIOS over IPv4 protocol. Additionally to the name resolution, the
nmbdservice 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. Thenmbsystemdservice starts and stops thenmbddaemon.Note that modern SMB networks use DNS to resolve clients and IP addresses. For Kerberos a working DNS setup is required.
To use the
nmbdservice, install thesambapackage.winbinddThis 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
winbindsystemdservice starts and stops thewinbindddaemon.If you set up Samba as a domain member,
winbinddmust be started before thesmbdservice. Otherwise, domain users and groups are not available to the local system.To use the
winbinddservice, install thesamba-winbindpackage.ImportantRed Hat only supports running Samba as a server with the
winbinddservice 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.samba-bgqd-
The Samba background queue daemon regularly updates the printer list with printers from CUPS. For print servers with multiple printers, run this daemon. It is managed by the
samba-bgqdsystemdservice. If it fails to run,rpcd_spoolssstarts it on demand.
1.1.2. The Samba security services Copy linkLink copied to clipboard!
The security parameter in the [global] section in the /etc/samba/smb.conf file manages how Samba authenticates users that are connecting to the service.
Depending on the mode you install Samba in, the parameter must be set to different values:
- On an AD domain member, set
security = ads In this mode, Samba uses Kerberos to authenticate AD users.
For details about setting up Samba as a domain member, see Setting up Samba as an AD domain member server
- On a standalone server, set
security = user In this mode, Samba uses a local database to authenticate connecting users.
For details about setting up Samba as a standalone server, see Setting up Samba as a standalone server.
- On an NT4 PDC or BDC, set
security = user - In this mode, Samba authenticates users to a local or LDAP database.
- On an NT4 domain member, set
security = domain In this mode, Samba authenticates connecting users to an NT4 PDC or BDC. You cannot use this mode on AD domain members.
For details about setting up Samba as a domain member, see Setting up Samba as an AD domain member server.
1.1.3. Scenarios when Samba services and Samba client utilities load and reload their configuration Copy linkLink copied to clipboard!
When Samba services and client utilities load or reload configuration files, details triggers for automatic and manual reloads, and certain settings require a full service restart for configuration changes to become effective.
The following describes when Samba services and utilities load and reload their configuration:
Samba services reload their configuration:
- Automatically every 3 minutes
-
On manual request, for example, when you run the
smbcontrol all reload-configcommand.
- 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. For more information, refer to:
-
The
How configuration changes are appliedsection in thesmb.conf(5)man page on your system -
smbd(8),nmbd(8), andwinbindd(8)man pages on your system
1.1.4. Editing the Samba configuration in a safe way Copy linkLink copied to clipboard!
Samba services automatically reload their configuration every 3 minutes. For details, see Scenarios when Samba services and Samba client utilities load and reload their configuration
To prevent that the services reload the changes before you have verified the configuration using the testparm utility, you can edit the Samba configuration in a safe way.
Prerequisites
- Samba is installed.
Procedure
Create a copy of the
/etc/samba/smb.conffile:cp /etc/samba/smb.conf /etc/samba/samba.conf.copy
# cp /etc/samba/smb.conf /etc/samba/samba.conf.copyCopy to Clipboard Copied! Toggle word wrap Toggle overflow - Edit the copied file and make the required changes.
Verify the configuration in the
/etc/samba/samba.conf.copyfile:testparm -s /etc/samba/samba.conf.copy
# testparm -s /etc/samba/samba.conf.copyCopy to Clipboard Copied! Toggle word wrap Toggle overflow If
testparmreports errors, fix them and run the command again.Override the
/etc/samba/smb.conffile with the new configuration:mv /etc/samba/samba.conf.copy /etc/samba/smb.conf
# mv /etc/samba/samba.conf.copy /etc/samba/smb.confCopy to Clipboard Copied! Toggle word wrap Toggle overflow Wait until the Samba services automatically reload their configuration or manually reload the configuration:
smbcontrol all reload-config
# smbcontrol all reload-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.2. Verifying the smb.conf file by using the testparm utility Copy linkLink copied to clipboard!
The testparm utility verifies that the Samba configuration in the /etc/samba/smb.conf file is correct. The utility detects invalid parameters and values, but also incorrect settings, such as for ID mapping. If testparm reports no problem, the Samba services will successfully load the /etc/samba/smb.conf file. Note that testparm cannot verify that the configured services will be available or work as expected.
Red Hat recommends that you verify the /etc/samba/smb.conf file by using testparm after each modification of this file.
Prerequisites
- You installed Samba.
-
The
/etc/samba/smb.conffile exists.
Procedure
Run the
testparmutility as therootuser:Copy to Clipboard Copied! Toggle word wrap Toggle overflow The previous example output reports a non-existent parameter and an incorrect ID mapping configuration.
-
If
testparmreports incorrect parameters, values, or other errors in the configuration, fix the problem and run the utility again.
1.3. Setting up Samba as a standalone server Copy linkLink copied to clipboard!
You can set up Samba as a server that is not a member of a domain. In this installation mode, Samba authenticates users to a local database instead of to a central DC. Additionally, you can enable guest access to allow users to connect to one or multiple services without authentication.
1.3.1. Setting up the server configuration for the standalone server Copy linkLink copied to clipboard!
You can set up the server configuration for a Samba standalone server. For more information, see the smb.conf(5) man page on your system.
Procedure
Install the
sambapackage:dnf install samba
# dnf install sambaCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the
/etc/samba/smb.conffile and set the following parameters:Copy to Clipboard Copied! Toggle word wrap Toggle overflow This configuration defines a standalone server named
Serverwithin theExample-WGwork 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%mmacro in thelog fileparameter to the NetBIOS name of connecting clients. This enables individual log files for each client.Optional: Configure file or printer sharing. See:
Verify the
/etc/samba/smb.conffile:testparm
# testparmCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you set up shares that require authentication, create the user accounts.
For details, see Creating and enabling local user accounts.
Open the required ports and reload the firewall configuration by using the
firewall-cmdutility:firewall-cmd --permanent --add-service=samba firewall-cmd --reload
# firewall-cmd --permanent --add-service=samba # firewall-cmd --reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable and start the
smbservice:systemctl enable --now smb
# systemctl enable --now smbCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.3.2. Creating and enabling local user accounts Copy linkLink copied to clipboard!
To enable users to authenticate when they connect to a share, you must create the accounts on the Samba host both in the operating system and in the Samba database. Samba requires the operating system account to validate the Access Control Lists (ACL) on file system objects and the Samba account to authenticate connecting users.
If you use the passdb backend = tdbsam default setting, Samba stores user accounts in the /var/lib/samba/private/passdb.tdb database.
You can create a local Samba user named example.
Prerequisites
- Samba is installed and configured as a standalone server.
Procedure
Create the operating system account:
useradd -M -s /sbin/nologin example
# useradd -M -s /sbin/nologin exampleCopy to Clipboard Copied! Toggle word wrap Toggle overflow This command adds the
exampleaccount without creating a home directory. If the account is only used to authenticate to Samba, assign the/sbin/nologincommand as shell to prevent the account from logging in locally.Set a password to the operating system account to enable it:
passwd example Enter new UNIX password: password Retype new UNIX password: password passwd: password updated successfully
# passwd example Enter new UNIX password: password Retype new UNIX password: password passwd: password updated successfullyCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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.
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.
# smbpasswd -a example New SMB password: password Retype new SMB password: password Added user example.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Use this password to authenticate when using this account to connect to a Samba share.
Enable the Samba account:
smbpasswd -e example Enabled user example.
# smbpasswd -e example Enabled user example.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.4. Understanding and configuring Samba ID mapping Copy linkLink copied to clipboard!
Windows domains distinguish users and groups by unique Security Identifiers (SID). However, Linux 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:
- The local database (default domain)
- The AD or NT4 domain the Samba server is a member of
- 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:
| Back end | Use case |
|---|---|
|
|
The |
|
| AD domains only |
|
| AD and NT4 domains |
|
|
AD, NT4, and the |
1.4.1. Planning Samba ID ranges Copy linkLink copied to clipboard!
Regardless of whether you store the Linux UIDs and GIDs in AD or if you configure Samba to generate them, each domain configuration requires a unique ID range that must not overlap with any of the other domains.
If you set overlapping ID ranges, Samba fails to work correctly.
Example 1.1. Unique ID Ranges
The following shows non-overlapping ID mapping ranges for the default (*), AD-DOM, and the TRUST-DOM domains.
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.
1.4.2. The * default domain Copy linkLink copied to clipboard!
You can configure the default Samba ID mapping domain to ensure proper ID assignment for local users, groups, and built-in accounts. Select and manage appropriate back ends to maintain system security, scalability, and compliance in domain environments.
In a domain environment, you add one ID mapping configuration for each of the following:
- The domain the Samba server is a member of
- 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:
- Local Samba users and groups
-
Samba built-in accounts and groups, such as
BUILTIN\Administrators
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:
tdbWhen you configure the default domain to use the
tdbback 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.conffile:idmap config * : backend = tdb idmap config * : range = 10000-999999
idmap config * : backend = tdb idmap config * : range = 10000-999999Copy to Clipboard Copied! Toggle word wrap Toggle overflow For further details, see Using the TDB ID mapping back end.
autoridWhen you configure the default domain to use the
autoridback end, adding additional ID mapping configurations for domains is optional.NoteThe range should be a multiple of the
rangesizeand must be at least twice its value to ensure sufficient id range space for the mandatoryBUILTINdomain. With a defaultrangesizeof 100000, the range must span at least 200000. For example, range = 100000 - 299999.For example, set the following in the
[global]section in the/etc/samba/smb.conffile:idmap config * : backend = autorid idmap config * : range = 10000-999999
idmap config * : backend = autorid idmap config * : range = 10000-999999Copy to Clipboard Copied! Toggle word wrap Toggle overflow For further details, see Using the autorid ID mapping back end.
1.4.3. Using the tdb ID mapping back end Copy linkLink copied to clipboard!
The winbindd service uses the writable tdb ID mapping back end by default to store Security Identifier (SID), UID, and GID mapping tables. This includes local users, groups, and built-in principals.
Use this back end only for the * default domain. For example:
idmap config * : backend = tdb idmap config * : range = 10000-999999
idmap config * : backend = tdb
idmap config * : range = 10000-999999
1.4.4. Using the ad ID mapping back end Copy linkLink copied to clipboard!
You can configure a Samba AD member to use the ad ID mapping back end.
The ad ID mapping back end implements a read-only API to read account and group information from AD. This provides the following benefits:
- All user and group settings are stored centrally in AD.
- 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.
The ad ID mapping back end does not support {AD} domains with one-way trusts. If you configure a domain member in an {AD} with one-way trusts, use instead one of the following ID mapping back ends: tdb, rid, or autorid.
The ad back end reads the following attributes from AD:
| AD attribute name | Object type | Mapped to |
|---|---|---|
|
| User and group | User or group name, depending on the object |
|
| User | User ID (UID) |
|
| Group | Group ID (GID) |
|
| User | Path to the shell of the user |
|
| User | Path to the home directory of the user |
|
| User | Primary group ID |
[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.conffile. 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.
- You installed Samba.
-
The Samba configuration, except ID mapping, exists in the
/etc/samba/smb.conffile.
Procedure
Edit the
[global]section in the/etc/samba/smb.conffile:Add an ID mapping configuration for the default domain (
*) if it does not exist. For example:idmap config * : backend = tdb idmap config * : range = 10000-999999
idmap config * : backend = tdb idmap config * : range = 10000-999999Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enable the
adID mapping back end for the AD domain:idmap config DOMAIN : backend = ad
idmap config DOMAIN : backend = adCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set the range of IDs that is assigned to users and groups in the AD domain. For example:
idmap config DOMAIN : range = 2000000-2999999
idmap config DOMAIN : range = 2000000-2999999Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantThe 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.
Set that Samba uses the RFC 2307 schema when reading attributes from AD:
idmap config DOMAIN : schema_mode = rfc2307
idmap config DOMAIN : schema_mode = rfc2307Copy to Clipboard Copied! Toggle word wrap Toggle overflow To enable Samba to read the login shell and the path to the users home directory from the corresponding AD attribute, set:
idmap config DOMAIN : unix_nss_info = yes
idmap config DOMAIN : unix_nss_info = yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow Alternatively, you can set a uniform domain-wide home directory path and login shell that is applied to all users. For example:
template shell = /bin/bash template homedir = /home/%U
template shell = /bin/bash template homedir = /home/%UCopy to Clipboard Copied! Toggle word wrap Toggle overflow By default, Samba uses the
primaryGroupIDattribute of a user object as the user’s primary group on Linux. Alternatively, you can configure Samba to use the value set in thegidNumberattribute instead:idmap config DOMAIN : unix_primary_group = yes
idmap config DOMAIN : unix_primary_group = yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verify the
/etc/samba/smb.conffile:testparm
# testparmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reload the Samba configuration:
smbcontrol all reload-config
# smbcontrol all reload-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.4.5. Using the rid ID mapping back end Copy linkLink copied to clipboard!
You can configure a Samba domain member to use the rid ID mapping back end.
Samba can use the relative identifier (RID) of a Windows SID to generate an ID on Red Hat Enterprise Linux.
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.
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.
Benefits of using the rid back end
- 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.
Drawbacks of using the rid back end
- 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
ridback 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
winbinddservice uses to calculate the IDs, duplicate IDs can occur in multi-domain environments if objects in different domains have the same RID.
Prerequisites
- You installed Samba.
-
The Samba configuration, except ID mapping, exists in the
/etc/samba/smb.conffile.
Procedure
Edit the
[global]section in the/etc/samba/smb.conffile:Add an ID mapping configuration for the default domain (
*) if it does not exist. For example:idmap config * : backend = tdb idmap config * : range = 10000-999999
idmap config * : backend = tdb idmap config * : range = 10000-999999Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enable the
ridID mapping back end for the domain:idmap config DOMAIN : backend = rid
idmap config DOMAIN : backend = ridCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set a range that is big enough to include all RIDs that will be assigned in the future. For example:
idmap config DOMAIN : range = 2000000-2999999
idmap config DOMAIN : range = 2000000-2999999Copy to Clipboard Copied! Toggle word wrap Toggle overflow Samba ignores users and groups whose RIDs in this domain are not within the range.
ImportantThe 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.
Set a shell and home directory path that will be assigned to all mapped users. For example:
template shell = /bin/bash template homedir = /home/%U
template shell = /bin/bash template homedir = /home/%UCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verify the
/etc/samba/smb.conffile:testparm
# testparmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reload the Samba configuration:
smbcontrol all reload-config
# smbcontrol all reload-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow For more information, see:
- The * default domain
-
VARIABLE SUBSTITUTIONSsection in thesmb.conf(5)man page on your system -
Calculation of the local ID from a RID, see the
idmap_rid(8)man page on your system
1.4.6. Using the autorid ID mapping back end Copy linkLink copied to clipboard!
You can configure a Samba domain member to use the autorid ID mapping back end.
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:
-
Only for the
*default domain -
For the
*default domain and additional domains, without the need to create ID mapping configurations for each of the additional domains - Only for specific domains
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.
Benefits of using the autorid back end
- All domain users and groups whose calculated UID and GID is within the configured range are automatically available on the domain member.
- 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
- You installed Samba.
-
The Samba configuration, except ID mapping, exists in the
/etc/samba/smb.conffile.
Procedure
Edit the
[global]section in the/etc/samba/smb.conffile:Enable the
autoridID mapping back end for the*default domain:idmap config * : backend = autorid
idmap config * : backend = autoridCopy to Clipboard Copied! Toggle word wrap Toggle overflow Set a range that is big enough to assign IDs for all existing and future objects. For example:
idmap config * : range = 10000-999999
idmap config * : range = 10000-999999Copy to Clipboard Copied! Toggle word wrap Toggle overflow Samba ignores users and groups whose calculated IDs in this domain are not within the range.
WarningAfter 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.
Optional: Set a range size. For example:
idmap config * : rangesize = 200000
idmap config * : rangesize = 200000Copy to Clipboard Copied! Toggle word wrap Toggle overflow Samba assigns this number of continuous IDs for each domain’s object until all IDs from the range set in the
idmap config * : rangeparameter are taken.NoteIf you set a rangesize, you need to adapt the range accordingly. The range needs to be a multiple of the rangesize.
Set a shell and home directory path that will be assigned to all mapped users. For example:
template shell = /bin/bash template homedir = /home/%U
template shell = /bin/bash template homedir = /home/%UCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Add additional ID mapping configuration for domains. If no configuration for an individual domain is available, Samba calculates the ID using the
autoridback end settings in the previously configured*default domain.ImportantThe 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.
Verify the
/etc/samba/smb.conffile:testparm
# testparmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reload the Samba configuration:
smbcontrol all reload-config
# smbcontrol all reload-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow For more information, see:
-
THE MAPPING FORMULASsection in theidmap_autorid(8)man page on your system -
rangesizeparameter description in theidmap_autorid(8)man page on your system -
VARIABLE SUBSTITUTIONSsection in thesmb.conf(5)man page on your system
-
1.5. Setting up Samba as an AD domain member server Copy linkLink copied to clipboard!
If you are running an AD or NT4 domain, use Samba to add your Red Hat Enterprise Linux server as a member to the domain.
This helps you to gain the following:
- Access domain resources on other domain members
-
Authenticate domain users to local services, such as
sshd - Share directories and printers hosted on the server to act as a file and print server
1.5.1. Joining a RHEL system to an AD domain Copy linkLink copied to clipboard!
Samba Winbind is an alternative to the System Security Services Daemon (SSSD) for connecting a Red Hat Enterprise Linux (RHEL) system with Active Directory (AD). You can join a RHEL system to an AD domain by using realmd to configure Samba Winbind. For more information see, the realm(8) man page on your system.
Procedure
If your AD requires the deprecated RC4 encryption type for Kerberos authentication, enable support for these ciphers in RHEL:
update-crypto-policies --set DEFAULT:AD-SUPPORT
# update-crypto-policies --set DEFAULT:AD-SUPPORTCopy to Clipboard Copied! Toggle word wrap Toggle overflow Install the following packages:
dnf install realmd oddjob-mkhomedir oddjob samba-winbind-clients \ samba-winbind samba-common-tools samba-winbind-krb5-locator krb5-workstation# dnf install realmd oddjob-mkhomedir oddjob samba-winbind-clients \ samba-winbind samba-common-tools samba-winbind-krb5-locator krb5-workstationCopy to Clipboard Copied! Toggle word wrap Toggle overflow To share directories or printers on the domain member, install the
sambapackage:dnf install samba
# dnf install sambaCopy to Clipboard Copied! Toggle word wrap Toggle overflow Backup the existing
/etc/samba/smb.confSamba configuration file:mv /etc/samba/smb.conf /etc/samba/smb.conf.bak
# mv /etc/samba/smb.conf /etc/samba/smb.conf.bakCopy to Clipboard Copied! Toggle word wrap Toggle overflow Join the domain. For example, to join a domain named
ad.example.com:realm join --membership-software=samba --client-software=winbind ad.example.com
# realm join --membership-software=samba --client-software=winbind ad.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Using the previous command, the
realmutility automatically:-
Creates a
/etc/samba/smb.conffile for a membership in thead.example.comdomain -
Adds the
winbindmodule for user and group lookups to the/etc/nsswitch.conffile -
Updates the Pluggable Authentication Module (PAM) configuration files in the
/etc/pam.d/directory -
Starts the
winbindservice and enables the service to start when the system boots
-
Creates a
Optional: Set an alternative ID mapping back end or customized ID mapping settings in the
/etc/samba/smb.conffile.For details, see Understanding and configuring Samba ID mapping.
Edit the
/etc/krb5.conffile and add the following section:[plugins] localauth = { module = winbind:/usr/lib64/samba/krb5/winbind_krb5_localauth.so enable_only = winbind }[plugins] localauth = { module = winbind:/usr/lib64/samba/krb5/winbind_krb5_localauth.so enable_only = winbind }Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the
winbindservice is running:systemctl status winbind ... Active: active (running) since Tue 2018-11-06 19:10:40 CET; 15s ago
# systemctl status winbind ... Active: active (running) since Tue 2018-11-06 19:10:40 CET; 15s agoCopy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantTo enable Samba to query domain user and group information, the
winbindservice must be running before you startsmb.If you installed the
sambapackage to share directories and printers, enable and start thesmbservice:systemctl enable --now smb
# systemctl enable --now smbCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Display an AD user’s details, such as the AD administrator account in the AD domain:
getent passwd "AD\administrator" AD\administrator:*:10000:10000::/home/administrator@AD:/bin/bash
# getent passwd "AD\administrator" AD\administrator:*:10000:10000::/home/administrator@AD:/bin/bashCopy to Clipboard Copied! Toggle word wrap Toggle overflow Query the members of the domain users group in the AD domain:
getent group "AD\Domain Users" AD\domain users:x:10000:user1,user2# getent group "AD\Domain Users" AD\domain users:x:10000:user1,user2Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: 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.txtfile toAD\administratorand the group toAD\Domain Users:chown "AD\administrator":"AD\Domain Users" /srv/samba/example.txt
# chown "AD\administrator":"AD\Domain Users" /srv/samba/example.txtCopy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that Kerberos authentication works as expected:
On the AD domain member, obtain a ticket for the
administrator@AD.EXAMPLE.COMprincipal:kinit administrator@AD.EXAMPLE.COM
# kinit administrator@AD.EXAMPLE.COMCopy to Clipboard Copied! Toggle word wrap Toggle overflow Display the cached Kerberos ticket:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Display the available domains:
wbinfo --all-domains BUILTIN SAMBA-SERVER AD
# wbinfo --all-domains BUILTIN SAMBA-SERVER ADCopy to Clipboard Copied! Toggle word wrap Toggle overflow
If you do not want to use the deprecated RC4 ciphers, you can enable the AES encryption type in AD. See Enabling the AES encryption type in Active Directory using a GPO.
1.5.2. Using the local authorization plug-in for MIT Kerberos Copy linkLink copied to clipboard!
The winbind service provides {AD} users to the domain member. In certain situations, administrators want to enable domain users to authenticate to local services, such as an SSH server, which are running on the domain member. When using Kerberos to authenticate the domain users, enable the winbind_krb5_localauth plug-in to correctly map Kerberos principals to {AD} accounts through the winbind service.
For example, if the sAMAccountName attribute of an {AD} 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
- Samba is configured as a member of an {AD}.
- Red Hat Enterprise Linux authenticates log in attempts against {AD}.
-
The
winbindservice is running.
Procedure
Edit the
/etc/krb5.conffile and add the following section:[plugins] localauth = { module = winbind:/usr/lib64/samba/krb5/winbind_krb5_localauth.so enable_only = winbind }[plugins] localauth = { module = winbind:/usr/lib64/samba/krb5/winbind_krb5_localauth.so enable_only = winbind }Copy to Clipboard Copied! Toggle word wrap Toggle overflow For more information, see the
winbind_krb5_localauth(8)man page on your system.
1.5.3. Enabling certificate auto-enrollment on a Samba client Copy linkLink copied to clipboard!
Certificate auto-enrollment is a function of the Active Directory (AD) Certificate Services. This feature enables users and devices enrollment for certificates without user interaction. Administrators can use certificates issued by the AD certificate authority (CA) in local services without manually monitor and renew certificates, which prevents disruptive outages.
If an AD provides a certificate authority (CA) and a RHEL host is a member of the AD, you can enable certificate auto-enrollment on the RHEL host. Samba then applies the auto-enrollment group policy from AD, and configures the certmonger service to request and manage certificates.
Prerequisites
- Samba is configured as a member of an AD.
A Windows server in the AD has the Active Directory Certificate Services server role with the following services installed:
- Certificate Authority
- Certificate Enrollment
- Policy Web Service
- Internet Information Services (ISS) is configured to provide the certificate auto-enrollment feature over HTTPS.
- ISS uses a certificate issued by the AD CA.
- The Certificate Enrollment service supports Kerberos Authentication.
- A group policy object (GPO) for certificate auto-enrollment is configured in AD.
Procedure
Install the
samba-gpupdatepackage:dnf install samba-gpupdate
# dnf install samba-gpupdateCopy to Clipboard Copied! Toggle word wrap Toggle overflow Append the following settings to the
/etc/samba/smb.conffile:kerberos method = secrets and keytab sync machine password to keytab = "/etc/krb5.keytab:account_name:sync_spns:spn_prefixes=host:sync_kvno:machine_password", "/etc/samba/cepces.keytab:account_name:machine_password" apply group policies = yes
kerberos method = secrets and keytab sync machine password to keytab = "/etc/krb5.keytab:account_name:sync_spns:spn_prefixes=host:sync_kvno:machine_password", "/etc/samba/cepces.keytab:account_name:machine_password" apply group policies = yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow The settings specified in the Samba configuration include the following configuration:
kerberos method = secrets and keytab-
Configures Samba to use the
/var/lib/samba/private/secrets.tdbfile first to verify Kerberos tickets and then the/etc/krb5.keytabfile. sync machine password to keytab = <list_of_keytab_files_and_their_principals>-
Defines paths to keytab files that Samba maintains and the Kerberos principals in these files. With the shown value, Samba continues maintaining the
/etc/krb5.keytabsystem keytab and, additionally, a/etc/samba/cepces.keytabfile that thecepces-submitsubmission helper forcertmongeruses to authenticate to the CA. apply group policies = yes-
Configures the
winbindservice to execute thegpupdatecommand in intervals. The update interval is 90 minutes, plus a random offset between 0 and 30 minutes.
Create the
/etc/samba/cepces.keytabfile:net ads keytab create
# net ads keytab createCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the
/etc/cepces/cepces.conffile, and make the following changes:In the
[global]section, set theservervariable to the fully-qualified domain name (FQDN) of the Windows server which runs the CA service:[global] server=win-server.ad.example.com
[global] server=win-server.ad.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow In the
[kerberos]section, set thekeytabvariable to/etc/samba/cepces.keytab:[kerberos] keytab=/etc/samba/cepces.keytab
[kerberos] keytab=/etc/samba/cepces.keytabCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Enable and start the
certmongerservice:systemctl enable --now certmonger
# systemctl enable --now certmongerCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
certmongerservice requests the certificates from the CA and automatically renews them before they expire.Manually run
samba-gpupdateto ensure that the group policies have been loaded from AD:samba-gpupdate
# samba-gpupdateCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
certmongerservice stores the keys and certificates in the following directories:-
Private keys:
/var/lib/samba/private/certs/ Issued certificates:
/var/lib/samba/certs/You can now start using the keys and certificates in services on the same host.
-
Private keys:
Optional: Display the certificates that
certmongermanages:Copy to Clipboard Copied! Toggle word wrap Toggle overflow By default, the Windows CA issues only a certificate by using the
Machinecertificate template. If you configured additional templates in the Windows CA that apply for this host,certmongerrequests certificates for these templates as well, and thegetcert listoutput includes also entries for them.
1.6. Setting up Samba on an IdM domain member Copy linkLink copied to clipboard!
You can set up Samba on a host that is joined to a Red Hat Identity Management (IdM) domain. Users from IdM and also, if available, from trusted Active Directory (AD) domains, can access shares and printer services provided by Samba.
Using Samba on an IdM domain member is an unsupported Technology Preview feature and contains certain limitations. For example, IdM trust controllers do not support the Active Directory Global Catalog service, and they do not support resolving IdM groups using the Distributed Computing Environment / Remote Procedure Calls (DCE/RPC) protocols. As a consequence, AD users can only access Samba shares and printers hosted on IdM clients when logged in to other IdM clients; AD users logged into a Windows machine cannot access Samba shares hosted on an IdM domain member.
Customers deploying Samba on IdM domain members are encouraged to provide feedback to Red Hat.
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.
1.6.1. Prerequisites Copy linkLink copied to clipboard!
- The host is joined as a client to the IdM domain.
- Both the IdM servers and the client must run on RHEL 10.
1.6.2. Preparing the IdM domain for installing Samba on domain members Copy linkLink copied to clipboard!
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.
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
- IdM server is installed.
- You have root privileges to install packages and restart IdM services.
Procedure
Install the required packages:
dnf install ipa-server-trust-ad samba-client
[root@ipaserver ~]# dnf install ipa-server-trust-ad samba-clientCopy to Clipboard Copied! Toggle word wrap Toggle overflow Authenticate as the IdM administrative user:
kinit admin
[root@ipaserver ~]# kinit adminCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the
ipa-adtrust-installutility:ipa-adtrust-install
[root@ipaserver ~]# ipa-adtrust-installCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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-installprints a list of service records that you must manually add to DNS before you can continue.The script prompts you that the
/etc/samba/smb.confalready exists and will be rewritten:WARNING: The smb.conf already exists. Running ipa-adtrust-install will break your existing Samba configuration. Do you wish to continue? [no]: yes
WARNING: The smb.conf already exists. Running ipa-adtrust-install will break your existing Samba configuration. Do you wish to continue? [no]: yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow The script prompts you to configure the
slapi-nisplug-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. Enable trusted domains support in slapi-nis? [no]: yes
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. Enable trusted domains support in slapi-nis? [no]: yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow You are prompted to run the SID generation task to create a SID for any existing users:
Do you want to run the ipa-sidgen task? [no]: yes
Do you want to run the ipa-sidgen task? [no]: yesCopy to Clipboard Copied! Toggle word wrap Toggle overflow This is a resource-intensive task, so if you have a high number of users, you can run this at another time.
Optional: By default, the Dynamic RPC port range is defined as
49152-65535for 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 to55000-65000.net conf setparm global 'rpc server dynamic port range' 55000-65000 firewall-cmd --add-port=55000-65000/tcp firewall-cmd --runtime-to-permanent
[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-permanentCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
ipaservice:ipactl restart
[root@ipaserver ~]# ipactl restartCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
smbclientutility to verify that Samba responds to Kerberos authentication from the IdM side:smbclient -L ipaserver.idm.example.com -U user_name --use-kerberos=required
[root@ipaserver ~]# smbclient -L ipaserver.idm.example.com -U user_name --use-kerberos=requiredCopy to Clipboard Copied! Toggle word wrap Toggle overflow lp_load_ex: changing to config backend registry Sharename Type Comment --------- ---- ------- IPC$ IPC IPC Service (Samba 4.15.2) ...lp_load_ex: changing to config backend registry Sharename Type Comment --------- ---- ------- IPC$ IPC IPC Service (Samba 4.15.2) ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.6.3. Installing and configuring a Samba server on an IdM client Copy linkLink copied to clipboard!
You can install and configure Samba on an IdM client to securely share files with integrated authentication, leveraging IdM domain accounts for access. Ensure proper prerequisites and configuration to enable seamless resource sharing across your network.
Prerequisites
- Both the IdM servers and the client must run on RHEL 10 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
Install the
ipa-client-sambapackage:dnf install ipa-client-samba
[root@idm_client]# dnf install ipa-client-sambaCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
ipa-client-sambautility to prepare the client and create an initial Samba configuration:Copy to Clipboard Copied! Toggle word wrap Toggle overflow By default,
ipa-client-sambaautomatically adds the[homes]section to the/etc/samba/smb.conffile 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[homes] read only = noCopy to Clipboard Copied! Toggle word wrap Toggle overflow Share directories and printers. For details, see:
Open the ports required for a Samba client in the local firewall:
firewall-cmd --permanent --add-service=samba-client firewall-cmd --reload
[root@idm_client]# firewall-cmd --permanent --add-service=samba-client [root@idm_client]# firewall-cmd --reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable and start the
smbandwinbindservices:systemctl enable --now smb winbind
[root@idm_client]# systemctl enable --now smb winbindCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Run the following verification step on a different IdM domain member that has the
samba-clientpackage installed:List the shares on the Samba server using Kerberos authentication:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow For more information, see the
ipa-client-samba(1)man page on your system.
1.6.4. Manually adding an ID mapping configuration if IdM trusts a new domain Copy linkLink copied to clipboard!
Samba requires an ID mapping configuration for each domain from which users access resources. On an existing Samba server running on an IdM client, you must manually add an ID mapping configuration after the administrator added a new trust to an Active Directory (AD) domain.
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. For security reasons, RHEL 10 does not support these weak encryption types.
Procedure
Authenticate using the host’s keytab:
kinit -k
[root@idm_client]# kinit -kCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
ipa idrange-findcommand to display both the base ID and the ID range size of the new domain. For example, the following command displays the values for thead.example.comdomain:Copy to Clipboard Copied! Toggle word wrap Toggle overflow You need the values from the
ipabaseidandipaidrangesizeattributes in the next steps.To calculate the highest usable ID, use the following formula:
maximum_range = ipabaseid + ipaidrangesize - 1
maximum_range = ipabaseid + ipaidrangesize - 1Copy to Clipboard Copied! Toggle word wrap Toggle overflow With the values from the previous step, the highest usable ID for the
ad.example.comdomain is1918599999(1918400000 + 200000 - 1).Edit the
/etc/samba/smb.conffile, and add the ID mapping configuration for the domain to the[global]section:idmap config AD : range = 1918400000 - 1918599999 idmap config AD : backend = sss
idmap config AD : range = 1918400000 - 1918599999 idmap config AD : backend = sssCopy to Clipboard Copied! Toggle word wrap Toggle overflow Specify the value from
ipabaseidattribute as the lowest and the computed value from the previous step as the highest value of the range.Restart the
smbandwinbindservices:systemctl restart smb winbind
[root@idm_client]# systemctl restart smb winbindCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
List the shares on the Samba server using Kerberos authentication:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.13. Configuring Samba for macOS clients Copy linkLink copied to clipboard!
The fruit virtual file system (VFS) Samba module provides enhanced compatibility with Apple server message block (SMB) clients.
1.15. Setting up Samba as a print server Copy linkLink copied to clipboard!
If you set up Samba as a print server, clients in your network can use Samba to print. Additionally, Windows clients can, if configured, download the driver from the Samba server.
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.
1.15.1. Prerequisites Copy linkLink copied to clipboard!
Samba has been set up in one of the following modes:
1.15.2. Enabling print server support in Samba Copy linkLink copied to clipboard!
By default, print server support is not enabled in Samba. To use Samba as a print server, you must configure Samba accordingly.
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
The printers are configured in a CUPS server.
For details about configuring printers in CUPS, see the documentation provided in the CUPS web console (https://printserver:631/help) on the print server.
Procedure
Edit the
/etc/samba/smb.conffile:Add the
[printers]section to enable the printing backend in Samba:[printers] comment = All Printers path = /var/tmp/ printable = yes create mask = 0600[printers] comment = All Printers path = /var/tmp/ printable = yes create mask = 0600Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantThe
[printers]share name is hard-coded and cannot be changed.If the CUPS server runs on a different host or port, specify the setting in the
[printers]section:cups server = printserver.example.com:631
cups server = printserver.example.com:631Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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
rpcd_spoolss:idle_seconds = 200Copy to Clipboard Copied! Toggle word wrap Toggle overflow If this setting does not scale in your environment, also increase the number of
rpcd_spoolssworkers in the[global]section:rpcd_spoolss:num_workers = 10
rpcd_spoolss:num_workers = 10Copy to Clipboard Copied! Toggle word wrap Toggle overflow By default,
rpcd_spoolssstarts 5 workers.
Verify the
/etc/samba/smb.conffile:testparm
# testparmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Open the required ports and reload the firewall configuration using the
firewall-cmdutility:firewall-cmd --permanent --add-service=samba firewall-cmd --reload
# firewall-cmd --permanent --add-service=samba # firewall-cmd --reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
smbservice:systemctl restart smb
# systemctl restart smbCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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
Verification
Submit a print job. For example, to print a PDF file, enter:
smbclient -Uuser //sambaserver.example.com/printer_name -c "print example.pdf"
# smbclient -Uuser //sambaserver.example.com/printer_name -c "print example.pdf"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.15.3. Manually sharing specific printers Copy linkLink copied to clipboard!
If you configured Samba as a print server, by default, Samba shares all printers that are configured in the CUPS back end. The following procedure explains how to share only specific printers.
Prerequisites
- Samba is set up as a print server
Procedure
Edit the
/etc/samba/smb.conffile:In the
[global]section, disable automatic printer sharing by setting:load printers = no
load printers = noCopy to Clipboard Copied! Toggle word wrap Toggle overflow Add a section for each printer you want to share. For example, to share the printer named
examplein the CUPS back end asExample-Printerin Samba, add the following section:[Example-Printer] path = /var/tmp/ printable = yes printer name = example[Example-Printer] path = /var/tmp/ printable = yes printer name = exampleCopy to Clipboard Copied! Toggle word wrap Toggle overflow You do not need individual spool directories for each printer. You can set the same spool directory in the
pathparameter for the printer as you set in the[printers]section.
Verify the
/etc/samba/smb.conffile:testparm
# testparmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reload the Samba configuration:
smbcontrol all reload-config
# smbcontrol all reload-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.16. Setting up automatic printer driver downloads for Windows clients on Samba print servers Copy linkLink copied to clipboard!
If you are running a Samba print server for Windows clients, you can upload drivers and preconfigure printers.
If a user connects to a printer, Windows automatically downloads and installs the driver locally on the client. The user does not require local administrator permissions for the installation. Additionally, Windows applies preconfigured driver settings, such as the number of trays.
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.
1.16.1. Prerequisites Copy linkLink copied to clipboard!
- Samba is set up as a print server
1.16.2. Basic information about printer drivers Copy linkLink copied to clipboard!
Learn key concepts about printer drivers in Samba, including supported versions and limitations. Understand driver preparation and how to provide compatible drivers for both 32-bit and 64-bit Windows clients in different environments.
Supported driver model version
Samba only supports the printer driver model version 3 which is supported in Windows 2000 and later, and Windows Server 2000 and later. Samba does not support the driver model version 4, introduced in Windows 8 and Windows Server 2012. However, these and later Windows versions also support version 3 drivers.
Package-aware drivers
Samba does not support package-aware drivers.
Preparing a printer driver for being uploaded
Before you can upload a driver to a Samba print server:
- Unpack the driver if it is provided in a compressed format.
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:
- Start the installer.
- Copy the files from the temporary folder to a new location.
- Cancel the installation.
Ask your printer manufacturer for drivers that support uploading to a print server.
Providing 32-bit and 64-bit drivers for a printer to a client
To provide the driver for a printer for both 32-bit and 64-bit Windows clients, you must upload a driver 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.
1.16.3. Enabling users to upload and preconfigure drivers Copy linkLink copied to clipboard!
To be able to upload and preconfigure printer drivers, a user or a group needs to have the SePrintOperatorPrivilege privilege granted. A user must be added into the printadmin group. Red Hat Enterprise Linux automatically creates this group when you install the samba package. The printadmin group gets assigned the lowest available dynamic system GID that is lower than 1000.
Procedure
For example, to grant the
SePrintOperatorPrivilegeprivilege to theprintadmingroup:net rpc rights grant "printadmin" SePrintOperatorPrivilege -U "DOMAIN\administrator" Enter DOMAIN\administrator's password: Successfully granted rights.
# net rpc rights grant "printadmin" SePrintOperatorPrivilege -U "DOMAIN\administrator" Enter DOMAIN\administrator's password: Successfully granted rights.Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteIn a domain environment, grant
SePrintOperatorPrivilegeto a domain group. This enables you to centrally manage the privilege by updating a user’s group membership.To list all users and groups having
SePrintOperatorPrivilegegranted:net rpc rights list privileges SePrintOperatorPrivilege -U "DOMAIN\administrator" Enter administrator's password: SePrintOperatorPrivilege: BUILTIN\Administrators DOMAIN\printadmin
# net rpc rights list privileges SePrintOperatorPrivilege -U "DOMAIN\administrator" Enter administrator's password: SePrintOperatorPrivilege: BUILTIN\Administrators DOMAIN\printadminCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.16.5. Creating a GPO to enable clients to trust the Samba print server Copy linkLink copied to clipboard!
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 Samba print server is a member of an AD domain.
- 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
-
Log into a Windows computer using an account that is allowed to edit group policies, such as the AD domain
Administratoruser. -
Open the
Group Policy Management Console. Right-click to your AD domain and select
Create a GPO in this domain, and Link it here.
-
Enter a name for the GPO, such as
Legacy Printer Driver Policyand clickOK. The new GPO will be displayed under the domain entry. -
Right-click to the newly-created GPO and select
Editto open theGroup Policy Management Editor. Navigate to → → → .
On the right side of the window, double-click
Point and Print Restrictionto edit the policy:Enable the policy and set the following options:
-
Select
Users can only point and print to these serversand enter the fully-qualified domain name (FQDN) of the Samba print server to the field next to this option. In both check boxes under
Security Prompts, selectDo not show warning or elevation prompt.
-
Select
- Click OK.
Double-click
Package Point and Print - Approved serversto edit the policy:-
Enable the policy and click the
Showbutton. Enter the FQDN of the Samba print server.
-
Close both the
Show Contentsand the policy’s properties window by clickingOK.
-
Enable the policy and click the
-
Close the
Group Policy Management Editor. Close the
Group Policy Management Console.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.
For using group policies, see the Windows documentation.
1.16.6. Uploading drivers and preconfiguring printers Copy linkLink copied to clipboard!
Use the Print Management application on a Windows client to upload drivers and preconfigure printers hosted on the Samba print server. For further details, see the Windows documentation.
1.17. Running Samba on a server with FIPS mode enabled Copy linkLink copied to clipboard!
This section provides an overview of the limitations of running Samba with FIPS mode enabled. It also provides the procedure for enabling FIPS mode on a Red Hat Enterprise Linux host running Samba.
1.17.1. Limitations of using Samba in FIPS mode Copy linkLink copied to clipboard!
Samba features have specific limitations when running in FIPS mode, with some modes working under certain conditions while others are restricted for security compliance.
The following Samba modes and features work in FIPS mode under the indicated conditions:
- Samba as a domain member only in Active Directory (AD) or Red Hat Enterprise Linux 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:
- NT LAN Manager (NTLM) authentication because RC4 ciphers are blocked
- The server message block version 1 (SMB1) protocol
- The stand-alone file server mode because it uses NTLM authentication
- NT4-style domain controllers
- 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:
- Running Samba as a print server
1.17.2. Using Samba in FIPS mode Copy linkLink copied to clipboard!
You can enable the FIPS mode on a RHEL host that runs Samba.
Prerequisites
- Samba is configured on the Red Hat Enterprise Linux host.
- Samba runs in a mode that is supported in FIPS mode.
Procedure
Enable the FIPS mode on RHEL:
fips-mode-setup --enable
# fips-mode-setup --enableCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reboot the server:
reboot
# rebootCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the
testparmutility to verify the configuration:testparm -s
# testparm -sCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the command displays any errors or incompatibilities, fix them to ensure that Samba works correctly.
1.18. Tuning the performance of a Samba server Copy linkLink copied to clipboard!
Learn what settings can improve the performance of Samba in certain situations, and which settings can have a negative performance impact.
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.
1.18.1. Prerequisites Copy linkLink copied to clipboard!
- Samba is set up as a file or print server
1.18.2. Setting the SMB protocol version Copy linkLink copied to clipboard!
Each new SMB version adds features and improves the performance of the protocol. The recent Windows and Windows Server operating systems always supports the latest protocol version. If Samba also uses the latest protocol version, Windows clients connecting to Samba benefit from the performance improvements. In Samba, the default value of the server max protocol is set to the latest supported stable SMB protocol version.
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
-
Remove the
server max protocolparameter from the[global]section in the/etc/samba/smb.conffile. Reload the Samba configuration
smbcontrol all reload-config
# smbcontrol all reload-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.18.4. Settings that can have a negative performance impact Copy linkLink copied to clipboard!
By default, the kernel in Red Hat Enterprise Linux is tuned for high network performance. For example, the kernel uses an auto-tuning mechanism for buffer sizes. Setting the socket options parameter in the /etc/samba/smb.conf file overrides these kernel settings. As a result, setting this parameter decreases the Samba network performance in most cases.
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. Configuring Samba to be compatible with clients that require an SMB version lower than the default Copy linkLink copied to clipboard!
Samba uses a reasonable and secure default value for the minimum server message block (SMB) version it supports. However, if you have clients that require an older SMB version, you can configure Samba to support it.
1.19.1. Setting the minimum SMB protocol version supported by a Samba server Copy linkLink copied to clipboard!
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. For more information, see the smb.conf(5) man page on your system.
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
- Samba is installed and configured.
Procedure
Edit the
/etc/samba/smb.conffile, add theserver min protocolparameter, and set the parameter to the minimum SMB protocol version the server should support. For example, to set the minimum SMB protocol version toSMB3, add:server min protocol = SMB3
server min protocol = SMB3Copy to Clipboard Copied! Toggle word wrap Toggle overflow Restart the
smbservice:systemctl restart smb
# systemctl restart smbCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.20. Frequently used Samba command-line utilities Copy linkLink copied to clipboard!
This chapter describes frequently used commands when working with a Samba server.
1.20.1. Using the net ads join and net rpc join commands Copy linkLink copied to clipboard!
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.
Red Hat recommends using the realm utility to join a domain. The realm utility automatically updates all involved configuration files.
Procedure
Manually create the
/etc/samba/smb.conffile with the following settings:For an AD domain member:
[global] workgroup = domain_name security = ads passdb backend = tdbsam realm = AD_REALM
[global] workgroup = domain_name security = ads passdb backend = tdbsam realm = AD_REALMCopy to Clipboard Copied! Toggle word wrap Toggle overflow For an NT4 domain member:
[global] workgroup = domain_name security = user passdb backend = tdbsam
[global] workgroup = domain_name security = user passdb backend = tdbsamCopy to Clipboard Copied! Toggle word wrap Toggle overflow
-
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.conffile. Verify the
/etc/samba/smb.conffile:testparm
# testparmCopy to Clipboard Copied! Toggle word wrap Toggle overflow Join the domain as the domain administrator:
To join an AD domain:
net ads join -U "DOMAIN\administrator"
# net ads join -U "DOMAIN\administrator"Copy to Clipboard Copied! Toggle word wrap Toggle overflow To join an NT4 domain:
net rpc join -U "DOMAIN\administrator"
# net rpc join -U "DOMAIN\administrator"Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Append the
winbindsource to thepasswdandgroupdatabase entry in the/etc/nsswitch.conffile:passwd: files winbind group: files winbind
passwd: files winbind group: files winbindCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable and start the
winbindservice:systemctl enable --now winbind
# systemctl enable --now winbindCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Configure PAM using the
authselectutility.For details, see the
authselect(8)man page on your system.Optional: For AD environments, configure the Kerberos client.
For details, see the documentation of your Kerberos client.
1.20.2. Using the net rpc rights command Copy linkLink copied to clipboard!
In Windows, you can assign privileges to accounts and groups to perform special operations, such as setting ACLs on a share or upload printer drivers. On a Samba server, you can use the net rpc rights command to manage privileges.
Listing privileges you can set
To list all available privileges and their owners, use the net rpc rights list command. For example:
Granting privileges
To grant a privilege to an account or group, use the net rpc rights grant command.
For example, grant the SePrintOperatorPrivilege privilege to the DOMAIN\printadmin group:
net rpc rights grant "DOMAIN\printadmin" SePrintOperatorPrivilege -U "DOMAIN\administrator" Enter DOMAIN\administrator's password: Successfully granted rights.
# net rpc rights grant "DOMAIN\printadmin" SePrintOperatorPrivilege -U "DOMAIN\administrator"
Enter DOMAIN\administrator's password:
Successfully granted rights.
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:
net rpc rights remoke "DOMAIN\printadmin" SePrintOperatorPrivilege -U "DOMAIN\administrator" Enter DOMAIN\administrator's password: Successfully revoked rights.
# net rpc rights remoke "DOMAIN\printadmin" SePrintOperatorPrivilege -U "DOMAIN\administrator"
Enter DOMAIN\administrator's password:
Successfully revoked rights.
1.20.4. Using the net user command Copy linkLink copied to clipboard!
The net user command enables you to perform the following actions on an AD DC or NT4 PDC:
- List all user accounts
- Add users
- Remove Users
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.
Listing domain user accounts
To list all users in an AD domain:
net ads user -U "DOMAIN\administrator"
# net ads user -U "DOMAIN\administrator"
To list all users in an NT4 domain:
net rpc user -U "DOMAIN\administrator"
# net rpc user -U "DOMAIN\administrator"
Adding a user account to the domain
On a Samba domain member, you can use the net user add command to add a user account to the domain.
For example, add the user account to the domain:
Add the account:
net user add user password -U "DOMAIN\administrator" User user added
# net user add user password -U "DOMAIN\administrator" User user addedCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Use the remote procedure call (RPC) shell to enable the account on the AD DC or NT4 PDC. For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Deleting a user account from the domain
On a Samba domain member, you can use the net user delete command to remove a user account from the domain.
For example, to remove the user account from the domain:
net user delete user -U "DOMAIN\administrator" User user deleted
# net user delete user -U "DOMAIN\administrator"
User user deleted
1.20.5. Using the rpcclient utility Copy linkLink copied to clipboard!
The rpcclient utility enables you to manually execute client-side Microsoft Remote Procedure Call (MS-RPC) functions on a local or remote SMB server. However, most of the features are integrated into separate utilities provided by Samba. Use rpcclient only for testing MS-PRC functions.
Prerequisites
-
The
samba-clientpackage is installed.
Procedure
You can use the
rpcclientutility to:Manage the printer Spool Subsystem (SPOOLSS) by assigning a driver to a printer:
rpcclient server_name -U "DOMAIN\administrator" -c 'setdriver "printer_name" "driver_name"' Enter DOMAIN\administrators password: Successfully set printer_name to driver driver_name.
# rpcclient server_name -U "DOMAIN\administrator" -c 'setdriver "printer_name" "driver_name"' Enter DOMAIN\administrators password: Successfully set printer_name to driver driver_name.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve information about an SMB server by listing all file shares and shared printers:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Perform actions using the Security Account Manager Remote (SAMR) protocol by listing Users on an SMB Server:
rpcclient server_name -U "DOMAIN\administrator" -c 'enumdomusers' Enter DOMAIN\administrators password: user:[user1] rid:[0x3e8] user:[user2] rid:[0x3e9]
# rpcclient server_name -U "DOMAIN\administrator" -c 'enumdomusers' Enter DOMAIN\administrators password: user:[user1] rid:[0x3e8] user:[user2] rid:[0x3e9]Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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.
For more information, please see the
rpcclient(1)man page on your system.
1.20.6. Using the samba-regedit application Copy linkLink copied to clipboard!
Certain settings, such as printer configurations, are stored in the registry on the Samba server. You can use the ncurses-based samba-regedit application to edit the registry of a Samba server.
Prerequisites
-
The
samba-clientpackage is installed.
Procedure
To start the application, enter:
samba-regedit
# samba-regeditCopy to Clipboard Copied! Toggle word wrap Toggle overflow Use the following keys:
- Cursor up and cursor down: Navigate through the registry tree and the values.
- Enter: Opens a key or edits a value.
-
Tab: Switches between the
KeyandValuepane. - Ctrl+C: Closes the application.
1.20.7. Using the smbcontrol utility Copy linkLink copied to clipboard!
The smbcontrol utility enables you to send command messages to the smbd, nmbd, winbindd, or all of these services. These control messages instruct the service, for example, to reload its configuration.
Prerequisites
-
The
samba-common-toolspackage is installed.
Procedure
Reload the configuration of the
smbd,nmbd,winbinddservices by sending thereload-configmessage type to thealldestination:smbcontrol all reload-config
# smbcontrol all reload-configCopy to Clipboard Copied! Toggle word wrap Toggle overflow For more information, see the
smbcontrol(1)man page on your system.
1.20.8. Using the smbpasswd utility Copy linkLink copied to clipboard!
The smbpasswd utility manages user accounts and passwords in the local Samba database. For more information, see the smbpasswd(8) man page on your system.
Prerequisites
-
The
samba-common-toolspackage is installed.
Procedure
If you run the command as a user,
smbpasswdchanges the Samba password of the user who run the command. For example:smbpasswd New SMB password: password Retype new SMB password: password
[user@server ~]$ smbpasswd New SMB password: password Retype new SMB password: passwordCopy to Clipboard Copied! Toggle word wrap Toggle overflow If you run
smbpasswdas therootuser, you can use the utility, for example, to:Create a new user:
smbpasswd -a user_name New SMB password: password Retype new SMB password: password Added user user_name.
[root@server ~]# smbpasswd -a user_name New SMB password: password Retype new SMB password: password Added user user_name.Copy to Clipboard Copied! Toggle word wrap Toggle overflow NoteBefore you can add a user to the Samba database, you must create the account in the local operating system.
Enable a Samba user:
smbpasswd -e user_name Enabled user user_name.
[root@server ~]# smbpasswd -e user_name Enabled user user_name.Copy to Clipboard Copied! Toggle word wrap Toggle overflow Disable a Samba user:
smbpasswd -x user_name Disabled user user_name
[root@server ~]# smbpasswd -x user_name Disabled user user_nameCopy to Clipboard Copied! Toggle word wrap Toggle overflow Delete a user:
smbpasswd -x user_name Deleted user user_name.
[root@server ~]# smbpasswd -x user_name Deleted user user_name.Copy to Clipboard Copied! Toggle word wrap Toggle overflow
1.20.9. Using the smbstatus utility Copy linkLink copied to clipboard!
The smbstatus utility reports on:
-
Connections per PID of each
smbddaemon 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
smbddaemon, 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
-
The
sambapackage is installed. -
The
smbdservice is running.
Procedure
Run the
smbstatusutility:Copy to Clipboard Copied! Toggle word wrap Toggle overflow For more information, see the
smbstatus(1)man page on your system.
1.20.10. Using the smbtar utility Copy linkLink copied to clipboard!
The smbtar utility backs up the content of an SMB share or a subdirectory of it and stores the content in a tar archive. Alternatively, you can write the content to a tape device. For more information, see the smbtar(1) man page on your system.
Prerequisites
-
The
samba-clientpackage is installed.
Procedure
Use the following command to back up the content of the
demodirectory on the//server/example/share and store the content in the/root/example.tararchive:smbtar -s server -x example -u user_name -p password -t /root/example.tar
# smbtar -s server -x example -u user_name -p password -t /root/example.tarCopy to Clipboard Copied! Toggle word wrap Toggle overflow
1.20.11. Using the wbinfo utility Copy linkLink copied to clipboard!
The wbinfo utility queries and returns information created and used by the winbindd service. For more information, see the wbinfo(1) man page on your system.
Prerequisites
-
The
samba-winbind-clientspackage is installed.
Procedure
You can use
wbinfo, for example, to:List domain users:
wbinfo -u AD\administrator AD\guest ...
# wbinfo -u AD\administrator AD\guest ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow List domain groups:
wbinfo -g AD\domain computers AD\domain admins AD\domain users ...
# wbinfo -g AD\domain computers AD\domain admins AD\domain users ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display the SID of a user:
wbinfo --name-to-sid="AD\administrator" S-1-5-21-1762709870-351891212-3141221786-500 SID_USER (1)
# wbinfo --name-to-sid="AD\administrator" S-1-5-21-1762709870-351891212-3141221786-500 SID_USER (1)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Display information about domains and trusts:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Chapter 2. Deploying an NFS server Copy linkLink copied to clipboard!
By using the Network File System (NFS) protocol, remote users can mount shared directories over a network and use them as they were mounted locally. This enables you to consolidate resources onto centralized servers on the network.
2.1. Key features of minor NFSv4 versions Copy linkLink copied to clipboard!
Each minor NFSv4 version brings enhancements aimed at improving performance and security. Use these improvements to utilize the full potential of NFSv4, ensuring efficient and reliable file sharing across networks.
Key features of NFSv4.2
- 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.
Key features of NFSv4.1
- Client-side support for pNFS
- The support of high-speed I/O to clustered servers enables you to store data on multiple machines, to provide direct access to data, and synchronization of updates to metadata.
- Sessions
Sessions maintain the state of the server relative to the connections belonging to a client. They provide two key features.
-
exactly-once-semantics(EOS) which helps to distinguish between the response of an old and new operation. - Bind multiple network connections for NFS operations, improving performance
-
Key features of NFSv4.0
- RPC and security
-
The
RPCSEC_GSSframework enhances RPC security. The NFSv4 protocol introduces a new operation for in-band security negotiation. This enables clients to query server policies for accessing file system resources securely. - Procedure and operation structure
-
NFS 4.0 introduces the
COMPOUNDprocedure, which enables clients to merge multiple operations into a single request to reduce RPCs. - File system model
NFS 4.0 retains the hierarchical file system model, treating files as byte streams and encoding names with UTF-8 for internationalization.
File handle types
With volatile file handles, servers can adjust to file system changes and enable clients to adapt as needed without requiring permanent file handles.
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.
- OPEN and CLOSE operations
- These operations can combine file lookup, creation, and semantic sharing at a single point, ensuring correct file sharing semantics.
- File locking
- File locking is part of the protocol, eliminating the need for RPC callbacks. File lock state is managed by the server under a lease-based model, where failure to renew the lease may result in state release by the server.
- Client caching and delegation
- Caching resembles previous versions, with client-determined timeouts for attribute and directory caching. Delegations in NFS 4.0 allow the server to assign certain responsibilities to the client, guaranteeing specific file sharing semantics and enabling local file operations without immediate server interaction.
2.2. The AUTH_SYS authentication method Copy linkLink copied to clipboard!
The AUTH_SYS method, which is also known as AUTH_UNIX, is a client authentication mechanism. With AUTH_SYS, the client sends the User ID (UID) and Group ID (GID) of the user to the server to verify its identity and permissions when accessing files.
It is considered less secure as it relies on the client-provided information, making it susceptible to unauthorized access if misconfigured.
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.
- User and Group ID mapping
-
NFS servers and clients can use the
idmapdservice to translate UIDs and GIDs between different systems for consistent identification and permission assignment.
2.3. The AUTH_GSS authentication method Copy linkLink copied to clipboard!
Kerberos is a network authentication protocol that allows secure authentication for clients and servers over a non-secure network. It uses symmetric key cryptography and requires a trusted Key Distribution Center (KDC) to authenticate users and services.
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:
-
sys: no cryptographic protection (default) -
krb5: authentication only -
krb5i: authentication and integrity protection -
krb5p: authentication, integrity checking, and traffic encryption
Note that the more cryptographic functionality a method provides, the lower is the performance.
2.4. File permissions on exported file systems Copy linkLink copied to clipboard!
File permissions on exported file systems determine access rights to files and directories for clients accessing them over NFS.
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.
For more information about this option, see the exports(5) man page on your system.
2.5. Services required on an NFS server Copy linkLink copied to clipboard!
Red Hat Enterprise Linux (RHEL) uses a combination of a kernel module and user-space processes to provide NFS file shares.
Principal services used by NFS servers include kernel modules and user-space processes that provide access to NFS file shares, with details on their functions and configuration.
| Service Name | NFS versions | Description |
|---|---|---|
|
| 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 |
|
| 3, 4 |
This service processes It checks that the requested NFS share is currently exported by the NFS server and that the client is allowed to access it. |
|
| 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.
The |
|
| 3, 4 | This service provides user quota information for remote users. |
|
| 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. |
|
| 3, 4 |
This service handles |
|
| 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. |
|
| 3 | This service provides notification to other NFSv3 clients when the local host reboots, and to the kernel when a remote NFSv3 host reboots. |
| Module Name | NFS versions | Description |
|---|---|---|
|
| 3, 4 | The NFS kernel module that services requests for shared NFS file systems. |
|
| 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. |
For more information, see the following man pages in your system:
-
rpcbind(8) -
rpc.mountd(8) -
rpc.nfsd(8) -
rpc.statd(8) -
rpc.rquotad(8) -
rpc.idmapd(8) -
gssproxy(8) -
nfsdcld(8)
2.6. The /etc/exports configuration file Copy linkLink copied to clipboard!
The /etc/exports file controls which directories the server exports. Each line contains an export point, a whitespace-separated list of clients that are allowed to mount the directory, and options for each of the clients.
The following is the format for an /etc/exports entry:
<directory> <host_or_network_1>(<options_1>) <host_or_network_n>(<options_n>)...
<directory> <host_or_network_1>(<options_1>) <host_or_network_n>(<options_n>)...
The following are the individual parts of an /etc/exports entry:
- <directory>
- 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)
/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:
| Default setting | Description |
|---|---|
|
| Exports the directory in read-only mode. |
|
| The NFS server does not reply to requests before changes made by previous requests are written to disk. |
|
| The server delays writing to the disk if it suspects another write request is pending.. |
|
|
Prevents that the |
You can view and manage exported file systems using the exportfs command. For details see the exportfs(8) man page on your system.
2.7. Configuring an NFSv4-only server Copy linkLink copied to clipboard!
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
Install the
nfs-utilspackage:dnf install nfs-utils
# dnf install nfs-utilsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Edit the
/etc/nfs.conffile, and make the following changes:Disable the
vers3parameter in the[nfsd]section to disable NFSv3:[nfsd] vers3=n
[nfsd] vers3=nCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: If you require only specific NFSv4 minor versions, uncomment all
vers4.<minor_version>parameters and set them accordingly, for example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow With this configuration, the server provides only NFS version 4.2.
ImportantIf you require only a specific NFSv4 minor version, set only the parameters for the minor versions. Do not uncomment the
vers4parameter to avoid an unpredictable activation or deactivation of minor versions. By default, thevers4parameter enables or disables all NFSv4 minor versions. However, this behavior changes if you setvers4in conjunction with otherversparameters.
Disable all NFSv3-related services:
systemctl mask --now rpc-statd.service rpcbind.service rpcbind.socket
# systemctl mask --now rpc-statd.service rpcbind.service rpcbind.socketCopy to Clipboard Copied! Toggle word wrap Toggle overflow Configure the
rpc.mountddaemon to not listen for NFSv3 mount requests. Create a/etc/systemd/system/nfs-mountd.service.d/v4only.conffile with the following content:[Service] ExecStart= ExecStart=/usr/sbin/rpc.mountd --no-tcp --no-udp
[Service] ExecStart= ExecStart=/usr/sbin/rpc.mountd --no-tcp --no-udpCopy to Clipboard Copied! Toggle word wrap Toggle overflow Reload the
systemdmanager configuration and restart thenfs-mountdservice:systemctl daemon-reload systemctl restart nfs-mountd
# systemctl daemon-reload # systemctl restart nfs-mountdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Create a directory that you want to share, for example:
mkdir -p /nfs/projects/
# mkdir -p /nfs/projects/Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you want to share an existing directory, skip this step.
Set the permissions you require on the
/nfs/projects/directory:chmod 2770 /nfs/projects/ chgrp users /nfs/projects/
# chmod 2770 /nfs/projects/ # chgrp users /nfs/projects/Copy to Clipboard Copied! Toggle word wrap Toggle overflow These commands set write permissions for the
usersgroup on the/nfs/projects/directory and ensure that the same group is automatically set on new entries created in this directory.Add an export point to the
/etc/exportsfile for each directory that you want to share:/nfs/projects/ 192.0.2.0/24(rw) 2001:db8::/32(rw)
/nfs/projects/ 192.0.2.0/24(rw) 2001:db8::/32(rw)Copy to Clipboard Copied! Toggle word wrap Toggle overflow This entry shares the
/nfs/projects/directory to be accessible with read and write access to clients in the192.0.2.0/24and2001:db8::/32subnets.Open the relevant ports in
firewalld:firewall-cmd --permanent --add-service nfs firewall-cmd --reload
# firewall-cmd --permanent --add-service nfs # firewall-cmd --reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable and start the NFS server:
systemctl enable --now nfs-server
# systemctl enable --now nfs-serverCopy to Clipboard Copied! Toggle word wrap Toggle overflow
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
# cat /proc/fs/nfsd/versions -3 +4 -4.0 -4.1 +4.2Copy to Clipboard Copied! Toggle word wrap Toggle overflow On a client, perform the following steps:
Install the
nfs-utilspackage:dnf install nfs-utils
# dnf install nfs-utilsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Mount an exported NFS share:
mount server.example.com:/nfs/projects/ /mnt/
# mount server.example.com:/nfs/projects/ /mnt/Copy to Clipboard Copied! Toggle word wrap Toggle overflow As a user which is a member of the
usersgroup, create a file in/mnt/:touch /mnt/file
# touch /mnt/fileCopy to Clipboard Copied! Toggle word wrap Toggle overflow List the directory to verify that the file was created:
ls -l /mnt/ total 0 -rw-r--r--. 1 demo users 0 Jan 16 14:18 file
# ls -l /mnt/ total 0 -rw-r--r--. 1 demo users 0 Jan 16 14:18 fileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.8. Configuring an NFSv3 server with optional NFSv4 support Copy linkLink copied to clipboard!
In a network which still uses NFSv3 clients, configure the server to provide shares by using the NFSv3 protocol. If you also have newer clients in your network, you can, additionally, enable NFSv4. By default, Red Hat Enterprise Linux NFS clients use the latest NFS version that the server provides.
Procedure
Install the
nfs-utilspackage:dnf install nfs-utils
# dnf install nfs-utilsCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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:Copy to Clipboard Copied! Toggle word wrap Toggle overflow With this configuration, the server provides only the NFS version 3 and 4.2.
ImportantIf you require only a specific NFSv4 minor version, set only the parameters for the minor versions. Do not uncomment the
vers4parameter to avoid an unpredictable activation or deactivation of minor versions. By default, thevers4parameter enables or disables all NFSv4 minor versions. However, this behavior changes if you setvers4in conjunction with otherversparameters.By default, NFSv3 RPC services use random ports. To enable a firewall configuration, configure fixed port numbers in the
/etc/nfs.conffile:In the
[lockd]section, set a fixed port number for thenlockmgrRPC service, for example:[lockd] port=5555
[lockd] port=5555Copy to Clipboard Copied! Toggle word wrap Toggle overflow With this setting, the service automatically uses this port number for both the UDP and TCP protocol.
In the
[statd]section, set a fixed port number for therpc.statdservice, for example:[statd] port=6666
[statd] port=6666Copy to Clipboard Copied! Toggle word wrap Toggle overflow With this setting, the service automatically uses this port number for both the UDP and TCP protocol.
Optional: Create a directory that you want to share, for example:
mkdir -p /nfs/projects/
# mkdir -p /nfs/projects/Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you want to share an existing directory, skip this step.
Set the permissions you require on the
/nfs/projects/directory:chmod 2770 /nfs/projects/ chgrp users /nfs/projects/
# chmod 2770 /nfs/projects/ # chgrp users /nfs/projects/Copy to Clipboard Copied! Toggle word wrap Toggle overflow These commands set write permissions for the
usersgroup on the/nfs/projects/directory and ensure that the same group is automatically set on new entries created in this directory.Add an export point to the
/etc/exportsfile for each directory that you want to share:/nfs/projects/ 192.0.2.0/24(rw) 2001:db8::/32(rw)
/nfs/projects/ 192.0.2.0/24(rw) 2001:db8::/32(rw)Copy to Clipboard Copied! Toggle word wrap Toggle overflow This entry shares the
/nfs/projects/directory to be accessible with read and write access to clients in the192.0.2.0/24and2001:db8::/32subnets.Open the relevant ports in
firewalld:firewall-cmd --permanent --add-service={nfs,rpc-bind,mountd} firewall-cmd --permanent --add-port={5555/tcp,5555/udp,6666/tcp,6666/udp} firewall-cmd --reload# firewall-cmd --permanent --add-service={nfs,rpc-bind,mountd} # firewall-cmd --permanent --add-port={5555/tcp,5555/udp,6666/tcp,6666/udp} # firewall-cmd --reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable and start the NFS server:
systemctl enable --now rpc-statd nfs-server
# systemctl enable --now rpc-statd nfs-serverCopy to Clipboard Copied! Toggle word wrap Toggle overflow
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
# cat /proc/fs/nfsd/versions +3 +4 -4.0 -4.1 +4.2Copy to Clipboard Copied! Toggle word wrap Toggle overflow On a client, perform the following steps:
Install the
nfs-utilspackage:dnf install nfs-utils
# dnf install nfs-utilsCopy to Clipboard Copied! Toggle word wrap Toggle overflow Mount an exported NFS share:
mount -o vers=<version> server.example.com:/nfs/projects/ /mnt/
# mount -o vers=<version> server.example.com:/nfs/projects/ /mnt/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the share was mounted with the specified NFS version:
mount | grep "/mnt" server.example.com:/nfs/projects/ on /mnt type nfs (rw,relatime,vers=3,...
# mount | grep "/mnt" server.example.com:/nfs/projects/ on /mnt type nfs (rw,relatime,vers=3,...Copy to Clipboard Copied! Toggle word wrap Toggle overflow As a user which is a member of the
usersgroup, create a file in/mnt/:touch /mnt/file
# touch /mnt/fileCopy to Clipboard Copied! Toggle word wrap Toggle overflow List the directory to verify that the file was created:
ls -l /mnt/ total 0 -rw-r--r--. 1 demo users 0 Jan 16 14:18 file
# ls -l /mnt/ total 0 -rw-r--r--. 1 demo users 0 Jan 16 14:18 fileCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.9. Enabling quota support on an NFS server Copy linkLink copied to clipboard!
If you want to restrict the amount of data a user or a group can store, you can configure quotas on the file system. On an NFS server, the rpc-rquotad service ensures that the quota is also applied to users on NFS clients. For more information, see the quota(1) and xfs_quota(8) man pages on your system.
Prerequisites
Procedure
Verify that quotas are enabled on the directories that you export:
For ext file system, enter:
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
# 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 offCopy to Clipboard Copied! Toggle word wrap Toggle overflow For an XFS file system, enter:
findmnt /nfs/projects TARGET SOURCE FSTYPE OPTIONS /nfs/projects /dev/sdb1 xfs rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,usrquota,grpquota
# findmnt /nfs/projects TARGET SOURCE FSTYPE OPTIONS /nfs/projects /dev/sdb1 xfs rw,relatime,seclabel,attr2,inode64,logbufs=8,logbsize=32k,usrquota,grpquotaCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Install the
quota-rpcpackage:dnf install quota-rpc
# dnf install quota-rpcCopy to Clipboard Copied! Toggle word wrap Toggle overflow 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 theRPCRQUOTADOPTSvariable in the/etc/sysconfig/rpc-rquotadfile:RPCRQUOTADOPTS="-p __<port_number>__"
RPCRQUOTADOPTS="-p __<port_number>__"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: By default, remote hosts can only read quotas. To allow clients to set quotas, append the
-Soption to theRPCRQUOTADOPTSvariable in the/etc/sysconfig/rpc-rquotadfile:RPCRQUOTADOPTS="-S"
RPCRQUOTADOPTS="-S"Copy to Clipboard Copied! Toggle word wrap Toggle overflow Open the port in
firewalld:firewall-cmd --permanent --add-port=875/udp firewall-cmd --reload
# firewall-cmd --permanent --add-port=875/udp # firewall-cmd --reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable and start the
rpc-rquotadservice:systemctl enable --now rpc-rquotad
# systemctl enable --now rpc-rquotadCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
On the client:
Mount the exported share:
mount server.example.com:/nfs/projects/ /mnt/
# mount server.example.com:/nfs/projects/ /mnt/Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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# 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 0Copy to Clipboard Copied! Toggle word wrap Toggle overflow To display the user and group quota on an XFS file system, enter:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.10. Enabling NFS over RDMA on an NFS server Copy linkLink copied to clipboard!
Remote Direct Memory Access (RDMA) is a protocol that enables a client system to directly transfer data from the memory of a storage server into its own memory. This enhances storage throughput, decreases latency in data transfer between the server and client, and reduces CPU load on both ends. If both the NFS server and clients are connected over RDMA, clients can use NFSoRDMA to mount an exported directory.
Prerequisites
- The NFS service is running and configured
- 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
Install the
rdma-corepackage:dnf install rdma-core
# dnf install rdma-coreCopy to Clipboard Copied! Toggle word wrap Toggle overflow If the package was already installed, verify that the
xprtrdmaandsvcrdmamodules in the/etc/rdma/modules/rdma.conffile are uncommented:# NFS over RDMA client support xprtrdma # NFS over RDMA server support svcrdma
# NFS over RDMA client support xprtrdma # NFS over RDMA server support svcrdmaCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: By default, NFS over RDMA uses port 20049. If you want to use a different port, set the
rdma-portsetting in the[nfsd]section of the/etc/nfs.conffile:rdma-port=<port>
rdma-port=<port>Copy to Clipboard Copied! Toggle word wrap Toggle overflow Open the NFSoRDMA port in
firewalld:firewall-cmd --permanent --add-port={20049/tcp,20049/udp} firewall-cmd --reload# firewall-cmd --permanent --add-port={20049/tcp,20049/udp} # firewall-cmd --reloadCopy to Clipboard Copied! Toggle word wrap Toggle overflow Adjust the port numbers if you set a different port than 20049.
Restart the
nfs-serverservice:systemctl restart nfs-server
# systemctl restart nfs-serverCopy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
On a client with InfiniBand hardware, perform the following steps:
Install the following packages:
dnf install nfs-utils rdma-core
# dnf install nfs-utils rdma-coreCopy to Clipboard Copied! Toggle word wrap Toggle overflow Mount an exported NFS share over RDMA:
mount -o rdma server.example.com:/nfs/projects/ /mnt/
# mount -o rdma server.example.com:/nfs/projects/ /mnt/Copy to Clipboard Copied! Toggle word wrap Toggle overflow If you set a port number other than the default (20049), pass
port=<port_number>to the command:mount -o rdma,port=<port_number> server.example.com:/nfs/projects/ /mnt/
# mount -o rdma,port=<port_number> server.example.com:/nfs/projects/ /mnt/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Verify that the share was mounted with the
rdmaoption:mount | grep "/mnt" server.example.com:/nfs/projects/ on /mnt type nfs (...,proto=rdma,...)
# mount | grep "/mnt" server.example.com:/nfs/projects/ on /mnt type nfs (...,proto=rdma,...)Copy to Clipboard Copied! Toggle word wrap Toggle overflow
2.11. Setting up an NFS server with Kerberos in an Identity Management domain Copy linkLink copied to clipboard!
If you use Red Hat Enterprise Linux Identity Management (IdM), you can join your NFS server to the IdM domain. This enables you to centrally manage users and groups and to use Kerberos for authentication, integrity protection, and traffic encryption.
Prerequisites
- The NFS server is enrolled in a Red Hat Enterprise Linux Identity Management (IdM) domain.
- The NFS server is running and configured.
Procedure
Obtain a kerberos ticket as an IdM administrator:
kinit admin
# kinit adminCopy to Clipboard Copied! Toggle word wrap Toggle overflow Create a
nfs/<FQDN>service principal:ipa service-add nfs/nfs_server.idm.example.com
# ipa service-add nfs/nfs_server.idm.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow Retrieve the
nfsservice principal from IdM, and store it in the/etc/krb5.keytabfile:ipa-getkeytab -s idm_server.idm.example.com -p nfs/nfs_server.idm.example.com -k /etc/krb5.keytab
# ipa-getkeytab -s idm_server.idm.example.com -p nfs/nfs_server.idm.example.com -k /etc/krb5.keytabCopy to Clipboard Copied! Toggle word wrap Toggle overflow Optional: Display the principals in the
/etc/krb5.keytabfile:Copy to Clipboard Copied! Toggle word wrap Toggle overflow By default, the IdM client adds the host principal to the
/etc/krb5.keytabfile when you join the host to the IdM domain. If the host principal is missing, use theipa-getkeytab -s idm_server.idm.example.com -p host/nfs_server.idm.example.com -k /etc/krb5.keytabcommand to add it.Use the
ipa-client-automountutility to configure mapping of IdM IDs.If the client is not in the IdM DNS domain, either use the
--domainoption to specify the primary DNS domain of the IdM deployment or the--serveroption to specify the IdM server to connect to:ipa-client-automount --domain idm.example.com
# ipa-client-automount --domain idm.example.comCopy to Clipboard Copied! Toggle word wrap Toggle overflow The
--domainoption triggers DNS discovery to determine the IdM servers to use.If the client is already in the IdM DNS domain, run the command without the
--domainoption:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Update your
/etc/exportsfile, and add the Kerberos security method to the client options. For example:/nfs/projects/ 192.0.2.0/24(rw,sec=krb5i)
/nfs/projects/ 192.0.2.0/24(rw,sec=krb5i)Copy to Clipboard Copied! Toggle word wrap Toggle overflow 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)
/nfs/projects/ 192.0.2.0/24(rw,sec=krb5:krb5i:krb5p)Copy to Clipboard Copied! Toggle word wrap Toggle overflow Reload the exported file systems:
exportfs -r
# exportfs -rCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.12. Configuring an NFS server with TLS support Copy linkLink copied to clipboard!
Without the RPCSEC_GSS protocol, NFS traffic is unencrypted by default. Starting with Red Hat Enterprise Linux 10, it is possible to configure NFS with TLS, allowing NFS traffic to be encrypted by default.
Prerequisites
- You have configured an NFSv4 server. For instructions, see Configuring an NFSv4-only server.
- You have a Certificate Authority (CA) certificate.
-
You have installed the
ktls-utilspackage.
Procedure
Create a private key and a certificate signing request (CSR):
openssl req -new -newkey rsa:4096 -noenc \ -keyout /etc/pki/tls/private/server.example.com.key \ -out /etc/pki/tls/private/server.example.com.csr \ -subj "/C=US/ST=State/L=City/O=Organization/CN=server.example.com" \ -addext "subjectAltName=DNS:server.example.com,IP:192.0.2.1"
# openssl req -new -newkey rsa:4096 -noenc \ -keyout /etc/pki/tls/private/server.example.com.key \ -out /etc/pki/tls/private/server.example.com.csr \ -subj "/C=US/ST=State/L=City/O=Organization/CN=server.example.com" \ -addext "subjectAltName=DNS:server.example.com,IP:192.0.2.1"Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantCommon Name (CN) and DNS must match the hostname. IP must match IP of the host.
-
Send the
/etc/pki/tls/private/server.example.com.csrfile to a CA and request a server certificate. Store the received CA certificate and the server certificate on the host. Import the CA certificate to the systems’s truststore:
cp ca.crt /etc/pki/ca-trust/source/anchors update-ca-trust
# cp ca.crt /etc/pki/ca-trust/source/anchors # update-ca-trustCopy to Clipboard Copied! Toggle word wrap Toggle overflow Move the server certificate to the
/etc/pki/tls/certs/directory:mv server.example.com.crt /etc/pki/tls/certs/
# mv server.example.com.crt /etc/pki/tls/certs/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure the SELinux context is correct on the private key and certificates:
restorecon -Rv /etc/pki/tls/certs/
# restorecon -Rv /etc/pki/tls/certs/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the server certificate and private key to the
[authenticate.server]section in the/etc/tlshd.conffile:x509.certificate= /etc/pki/tls/certs/server.example.com.crt x509.private_key= /etc/pki/tls/private/server.example.com.key
x509.certificate= /etc/pki/tls/certs/server.example.com.crt x509.private_key= /etc/pki/tls/private/server.example.com.keyCopy to Clipboard Copied! Toggle word wrap Toggle overflow Leave the
x509.truststoreparameter unset.Enable and start the
tlshdservice:systemctl enable --now tlshd.service
# systemctl enable --now tlshd.serviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.13. Configuring an NFS client with TLS support Copy linkLink copied to clipboard!
If the server supports NFS with TLS encryption, you can configure the client accordingly and use the xprtsec=tls parameter to mount it with TLS support.
Prerequisites
- You have configured the NFS server with TLS encryption. For details, see Configuring an NFS server with TLS support.
-
You have installed the
ktls-utilspackage.
Procedure
Import the Certificate Authority (CA) certificate to the systems’s truststore:
cp ca.crt /etc/pki/ca-trust/source/anchors update-ca-trust
# cp ca.crt /etc/pki/ca-trust/source/anchors # update-ca-trustCopy to Clipboard Copied! Toggle word wrap Toggle overflow Enable and start the
tlshdservice:systemctl enable --now tlshd.service
# systemctl enable --now tlshd.serviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow Mount an NFS share by using TLS encryption:
mount -o xprtsec=tls server.example.com:/nfs/projects/ /mnt/
# mount -o xprtsec=tls server.example.com:/nfs/projects/ /mnt/Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the client successfully mounted NFS share with TLS support:
journalctl -u tlshd … Apr 01 08:37:56 client.example.com tlshd[10688]: Handshake with server.example.com (192.0.2.1) was successful
# journalctl -u tlshd … Apr 01 08:37:56 client.example.com tlshd[10688]: Handshake with server.example.com (192.0.2.1) was successfulCopy to Clipboard Copied! Toggle word wrap Toggle overflow
2.14. Configuring an NFS client with mutual TLS support Copy linkLink copied to clipboard!
If the server supports NFS with TLS encryption, you can configure the NFS server and client to authenticate each other by using TLS protocol.
Prerequisites
- You have configured the NFS server with TLS encryption. For details, see Configuring an NFS server with TLS support.
-
You have installed the
ktls-utilspackage.
Procedure
Create a private key and a certificate signing request (CSR):
openssl req -new -newkey rsa:4096 -noenc \ -keyout /etc/pki/tls/private/client.example.com.key \ -out /etc/pki/tls/private/client.example.com.csr \ -subj "/C=US/ST=State/L=City/O=Organization/CN=client.example.com" \ -addext "subjectAltName=DNS:client.example.com,IP:192.0.2.2"
# openssl req -new -newkey rsa:4096 -noenc \ -keyout /etc/pki/tls/private/client.example.com.key \ -out /etc/pki/tls/private/client.example.com.csr \ -subj "/C=US/ST=State/L=City/O=Organization/CN=client.example.com" \ -addext "subjectAltName=DNS:client.example.com,IP:192.0.2.2"Copy to Clipboard Copied! Toggle word wrap Toggle overflow ImportantCommon Name (CN) and DNS must match the hostname. IP must match IP of the host.
-
Send the
/etc/pki/tls/private/client.example.com.csrfile to a Certificate Authority (CA) and request a client certificate. Store the received CA certificate and the client certificate on the host. Import the CA certificate to the systems’s truststore:
cp ca.crt /etc/pki/ca-trust/source/anchors update-ca-trust
# cp ca.crt /etc/pki/ca-trust/source/anchors # update-ca-trustCopy to Clipboard Copied! Toggle word wrap Toggle overflow Move the client certificate to the
/etc/pki/tls/certs/directory:mv client.example.com.crt /etc/pki/tls/certs/
# mv client.example.com.crt /etc/pki/tls/certs/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Ensure the SELinux context is correct on the private key and certificates:
restorecon -Rv /etc/pki/tls/certs/
# restorecon -Rv /etc/pki/tls/certs/Copy to Clipboard Copied! Toggle word wrap Toggle overflow Add the client certificate and private key to the
[authenticate.client]section in the/etc/tlshd.conffile:x509.certificate= /etc/pki/tls/certs/client.example.com.crt x509.private_key= /etc/pki/tls/private/client.example.com.key
x509.certificate= /etc/pki/tls/certs/client.example.com.crt x509.private_key= /etc/pki/tls/private/client.example.com.keyCopy to Clipboard Copied! Toggle word wrap Toggle overflow Leave the
x509.truststoreparameter unset.Enable and start the
tlshdservice:systemctl enable --now tlshd.service
# systemctl enable --now tlshd.serviceCopy to Clipboard Copied! Toggle word wrap Toggle overflow Mount an NFS share by using TLS encryption:
mount -o xprtsec=mtls server.example.com:/nfs/projects/ /mnt/
# mount -o xprtsec=mtls server.example.com:/nfs/projects/ /mnt/Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Verification
Verify that the client successfully mounted NFS share with TLS support:
journalctl -u tlshd … Apr 01 08:37:56 client.example.com tlshd[10688]: Handshake with server.example.com (192.0.2.1) was successful
# journalctl -u tlshd … Apr 01 08:37:56 client.example.com tlshd[10688]: Handshake with server.example.com (192.0.2.1) was successfulCopy to Clipboard Copied! Toggle word wrap Toggle overflow