This chapter provides information regarding the types of server that Samba may be configured to be. AMicrosoft network administrator who wishes to migrate to or use Samba will want to know the meaning, within aSamba context, of terms familiar to the MS Windows administrator. This means that it is essential also todefine how critical security modes function before we get into the details of how to configure the serveritself.
This chapter provides an overview of the security modes of which Samba is capable and how they relate to MSWindows servers and clients.
A question often asked is, “Why would I want to use Samba?” Most chapters contain a section thathighlights features and benefits. We hope that the information provided will help to answer this question. Bewarned though, we want to be fair and reasonable, so not all features are positive toward Samba. The benefitmay be on the side of our competition.
Two men were walking down a dusty road, when one suddenly kicked up a small red stone. Ithurt his toe and lodged in his sandal. He took the stone out and cursed it with a passionand fury befitting his anguish. The other looked at the stone and said, “This is a garnet.I can turn that into a precious gem and some day it will make a princess very happy!”
The moral of this tale: Two men, two very different perspectives regarding the same stone.Like it or not, Samba is like that stone. Treat it the right way and it can bring greatpleasure, but if you are forced to use it and have no time for its secrets, then it can bea source of discomfort.
Samba started out as a project that sought to provide interoperability for MS Windows 3.xclients with a UNIX server. It has grown up a lot since its humble beginnings and now providesfeatures and functionality fit for large-scale deployment. It also has some warts. In sectionslike this one, we tell of both.
So, what are the benefits of the features mentioned in this chapter?
Samba-3 offers excellent interoperability with MS Windows NT4-styledomains as well as natively with Microsoft Active Directory domains.
Samba has security modes that permit more flexible authenticationthan is possible with MS Windows NT4 domain controllers.
Samba-3 permits use of multiple concurrent account database backends.(Encrypted passwords that are stored in the account database are informats that are unique to Windows networking).
The account database backends can be distributedand replicated using multiple methods. This gives Samba-3greater flexibility than MS Windows NT4 and in many cases asignificantly higher utility than Active Directory domainswith MS Windows 200x.
Administrators of Microsoft networks often refer to three different types of servers:
Domain Controller
Primary Domain Controller (PDC)
Backup Domain Controller (BDC)
ADS Domain Controller
Domain Member Server
Active Directory Domain Server
NT4 Style Domain Domain Server
Standalone Server
The chapters covering domain control (Domain Control), backup domain control (Backup Domain Control), and domain membership (Domain Membership) providepertinent information regarding Samba configuration for each of these server roles.You are strongly encouraged to become intimately familiar with these chapters becausethey lay the foundation for deployment of Samba domain security.
A Standalone server is autonomous in respect of the source of its account backend.Refer to Standalone Servers to gain a wider appreciationof what is meant by a server being configured as a standalone server.
In this section, the function and purpose of Samba's security modes are described. An accurate understanding ofhow Samba implements each security mode as well as how to configure MS Windows clients for each mode willsignificantly reduce user complaints and administrator heartache.
Microsoft Windows networking uses a protocol that was originally called the Server Message Block (SMB)protocol. Since some time around 1996 the protocol has been better known as the Common Internet Filesystem(CIFS) protocol.
In the SMB/CIFS networking world, there are only two types of security: user-level andshare level. We refer to these collectively as security levels. Inimplementing these two security levels, Samba provides flexibilities that are not available with MS WindowsNT4/200x servers. In fact, Samba implements share-level security only one way, but hasfour ways of implementing user-level security. Collectively, we call the Sambaimplementations of the security levels security modes. They are known asshare, user, domain, ADS,and server modes. They are documented in this chapter.
An SMB server informs the client, at the time of a session setup, the security level the server is running.There are two options: share-level and user-level. Which of these two the client receives affects the way theclient then tries to authenticate itself. It does not directly affect (to any great extent) the way the Sambaserver does security. This may sound strange, but it fits in with the client/server approach of SMB. In SMBeverything is initiated and controlled by the client, and the server can only tell the client what isavailable and whether an action is allowed.
The term client
refers to all agents whether it is a Windows workstation, a Windows server,another Samba server, or any vanilla SMB or CIFS client application (e.g., smbclient
) thatmake use of services provided by an SMB/CIFS server.
We describe user-level security first because its simpler. In user-level security, the client sends a sessionsetup request directly following protocol negotiation. This request provides a username and password. Theserver can either accept or reject that username/password combination. At this stage the server has no ideawhat share the client will eventually try to connect to, so it can't base theaccept/reject on anything other than:
the username/password.
the name of the client machine.
If the server accepts the username/password credentials, the client expects to be able to mount shares (usinga tree connection) without further specifying a password. It expects that all accessrights will be as the username/password credentials set that was specified in the initial sessionsetup.
It is also possible for a client to send multiple session setuprequests. When the server responds, it gives the client a uid to useas an authentication tag for that username/password. The client can maintain multipleauthentication contexts in this way (WinDD is an example of an application that does this).
Windows networking user account names are case-insensitive, meaning that upper-case and lower-case charactersin the account name are considered equivalent. They are said to be case-preserving, but not case significant.Windows and LanManager systems previous to Windows NT version 3.10 have case-insensitive passwords that werenot necessarily case-preserving. All Windows NT family systems treat passwords as case-preserving andcase-sensitive.
In share-level security, the client authenticates itself separately for each share. It sends a password alongwith each tree connection request (share mount), but it does not explicitly send a username with thisoperation. The client expects a password to be associated with each share, independent of the user. This meansthat Samba has to work out what username the client probably wants to use,because the username is not explicitly sent to the SMB server. Some commercial SMB servers such as NT actually associate passwords directly with sharesin share-level security, but Samba always uses the UNIX authentication scheme where it is a username/passwordpair that is authenticated, not a share/password pair.
To understand the MS Windows networking parallels, think in terms of MS Windows 9x/Me where you can create ashared folder that provides read-only or full access, with or without a password.
Many clients send a session setup request even if the server is in share-level security. They normally send a validusername but no password. Samba records this username in a list of possible usernames. When the client thenissues a tree connection request, it also adds to this list the name of the share they try to connect to (useful forhome directories) and any users listed in the user parameter in the smb.conf
file.The password is then checked in turn against these possible usernames. If a match is found, then the client isauthenticated as that user.
Where the list of possible user names is not provided, Samba makes a UNIX system call to find the useraccount that has a password that matches the one provided from the standard account database. On a system thathas no name service switch (NSS) facility, such lookups will be from the /etc/passwd
database. On NSS enabled systems, the lookup will go to the libraries that have been specified in thensswitch.conf
file. The entries in that file in which the libraries are specified are:
passwd: files nis ldapshadow: files nis ldapgroup: files nis ldap
In the example shown here (not likely to be used in practice) the lookup will check/etc/passwd
and /etc/group
, if not found it will check NIS, thenLDAP.
Domain security provides a mechanism for storing all user and group accounts in a central, shared, accountrepository. The centralized account repository is shared between domain (security) controllers. Servers thatact as domain controllers provide authentication and validation services to all machines that participate inthe security context for the domain. A primary domain controller (PDC) is a server that is responsible formaintaining the integrity of the security account database. Backup domain controllers (BDCs) provide only domainlogon and authentication services. Usually, BDCs will answer network logon requests more responsively thanwill a PDC.
When Samba is operating in security = domain mode, the Samba server has adomain security trust account (a machine account) and causes all authentication requests to be passed throughto the domain controllers. In other words, this configuration makes the Samba server a domain member server,even when it is in fact acting as a domain controller. All machines that participate in domain security musthave a machine account in the security database.
Within the domain security environment, the underlying security architecture uses user-level security. Evenmachines that are domain members must authenticate on startup. The machine account consists of an accountentry in the accounts database, the name of which is the NetBIOS name of the machine and of which the passwordis randomly generated and known to both the domain controllers and the member machine. If the machine accountcannot be validated during startup, users will not be able to log on to the domain using this machine becauseit cannot be trusted. The machine account is referred to as a machine trust account.
There are three possible domain member configurations:
Primary domain controller (PDC) - of which there is one per domain.
Backup domain controller (BDC) - of which there can be any number per domain.
Domain member server (DMS) - of which there can be any number per domain.
We will discuss each of these in separate chapters. For now, we are most interested in basic DMSconfiguration.
Samba as a Domain Member Server
This method involves addition of the following parameters in the smb.conf
file:
security = domain |
workgroup = MIDEARTH |
In order for this method to work, the Samba server needs to join the MS Windows NTsecurity domain. This is done as follows:
On the MS Windows NT domain controller, using the Server Manager, add a machine account for the Samba server.
On the UNIX/Linux system execute:
root#
net rpc join -U administrator%password
Note
Samba-2.2.4 and later Samba 2.2.x series releases can autojoin a Windows NT4-style domain just by executing:
root#
smbpasswd -j
DOMAIN_NAME
-rPDC_NAME
\ -U Administrator%password
Samba-3 can do the same by executing:
root#
net rpc join -U Administrator%
password
It is not necessary with Samba-3 to specify the DOMAIN_NAME
or thePDC_NAME
, as it figures this out from the smb.conf
file settings.
Use of this mode of authentication requires there to be a standard UNIX account for each user in order toassign a UID once the account has been authenticated by the Windows domain controller. This account can beblocked to prevent logons by clients other than MS Windows through means such as setting an invalid shell inthe /etc/passwd
entry. The best way to allocate an invalid shell to a user account is toset the shell to the file /bin/false
.
Domain controllers can be located anywhere that is convenient. The best advice is to have a BDC on everyphysical network segment, and if the PDC is on a remote network segment the use of WINS (see Network Browsing for more information) is almost essential.
An alternative to assigning UIDs to Windows users on a Samba member server is presented in Winbind, Winbind: Use of Domain Accounts.
For more information regarding domain membership, Domain Membership.
Both Samba-2.2, and Samba-3 can join an Active Directory domain using NT4 style RPC based security. This ispossible if the domain is run in native mode. Active Directory in native mode perfectly allows NT4-styledomain members. This is contrary to popular belief.
If you are using Active Directory, starting with Samba-3 you can join as a native AD member. Why would youwant to do that? Your security policy might prohibit the use of NT-compatible authentication protocols. Allyour machines are running Windows 2000 and above and all use Kerberos. In this case, Samba, as an NT4-styledomain, would still require NT-compatible authentication data. Samba in AD-member mode can accept Kerberostickets.
Sites that use Microsoft Windows active directory services (ADS) should be aware of the significance of theterms: native mode
and mixed mode
ADS operation. The termrealm
is used to describe a Kerberos-based security architecture (such as is used byMicrosoft ADS).
Server security mode is left over from the time when Samba was not capable of actingas a domain member server. It is highly recommended not to use this feature. Serversecurity mode has many drawbacks that include:
Potential account lockout on MS Windows NT4/200x password servers.
Lack of assurance that the password server is the one specified.
Does not work with Winbind, which is particularly needed when storing profiles remotely.
This mode may open connections to the password server and keep them open for extended periods.
Security on the Samba server breaks badly when the remote password server suddenly shuts down.
With this mode there is NO security account in the domain that the password server belongs to for the Samba server.
In server security mode the Samba server reports to the client that it is in user-level security. The clientthen does a session setup as described earlier. The Samba server takes the username/password that the clientsends and attempts to log into the password server by sending exactly the sameusername/password that it got from the client. If that server is in user-level security and accepts thepassword, then Samba accepts the client's connection. This parameter allows the Samba server to use anotherSMB server as the password server.
You should also note that at the start of all this, when the server tells the clientwhat security level it is in, it also tells the client if it supports encryption. If itdoes, it supplies the client with a random cryptkey. The client will then send allpasswords in encrypted form. Samba supports this type of encryption by default.
The parameter security = server means that Samba reports to clients thatit is running in user mode but actually passes off all authentication requests to anotheruser mode server. This requires an additional parameter password server that points tothe real authentication server. The real authentication server can be another Samba server, or it can be aWindows NT server, the latter being natively capable of encrypted password support.
Note
When Samba is running in server security mode, it is essential that the parameterpassword server is set to the precise NetBIOS machine name of the target authenticationserver. Samba cannot determine this from NetBIOS name lookups because the choice of the target authenticationserver is arbitrary and cannot be determined from a domain name. In essence, a Samba server that is inserver security mode is operating in what used to be known as workgroup mode.
Using MS Windows NT as an Authentication Server
This method involves the additions of the following parameters in the smb.conf
file:
encrypt passwords = Yes |
security = server |
password server = "NetBIOS_name_of_a_DC" |
There are two ways of identifying whether or not a username and password pair is valid.One uses the reply information provided as part of the authentication messagingprocess, the other uses just an error code.
The downside of this mode of configuration is that for security reasons Sambawill send the password server a bogus username and a bogus password, and if the remoteserver fails to reject the bogus username and password pair, then an alternative mode ofidentification or validation is used. Where a site uses password lockout, after acertain number of failed authentication attempts, this will result in user lockouts.
Use of this mode of authentication requires a standard UNIX account for the user.This account can be blocked to prevent logons by non-SMB/CIFS clients.
MS Windows clients may use encrypted passwords as part of a challenge/responseauthentication model (a.k.a. NTLMv1 and NTLMv2) or alone, or clear-text strings for simplepassword-based authentication. It should be realized that with the SMB protocol,the password is passed over the network either in plaintext or encrypted, butnot both in the same authentication request.
When encrypted passwords are used, a password that has been entered by the useris encrypted in two ways:
An MD4 hash of the unicode of the password string. This is known as the NT hash.
The password is converted to uppercase, and then padded or truncated to 14 bytes. This string is then appended with 5 bytes of NULL characters and split to form two 56-bit DES keys to encrypt a "magic" 8-byte value. The resulting 16 bytes form the LanMan hash.
MS Windows 95 pre-service pack 1 and MS Windows NT versions 3.x and version 4.0 pre-service pack 3 will useeither mode of password authentication. All versions of MS Windows that follow these versions no longersupport plain-text passwords by default.
MS Windows clients have a habit of dropping network mappings that have been idlefor 10 minutes or longer. When the user attempts to use the mapped driveconnection that has been dropped, the client re-establishes the connection usinga cached copy of the password.
When Microsoft changed the default password mode, support was dropped for cachingof the plaintext password. This means that when the registry parameter is changedto re-enable use of plaintext passwords, it appears to work, but when a droppedservice connection mapping attempts to revalidate, this will fail if the remoteauthentication server does not support encrypted passwords. It is definitely nota good idea to re-enable plaintext password support in such clients.
The following parameters can be used to work around the issue of Windows 9x/Me clientsuppercasing usernames and passwords before transmitting them to the SMB serverwhen using clear-text authentication:
By default Samba will convert to lowercase the username before attempting to lookup the userin the database of local system accounts. Because UNIX usernames conventionallyonly contain lowercase characters, the username-level parameteris rarely needed.
However, passwords on UNIX systems often make use of mixed-case characters. This means that in order for auser on a Windows 9x/Me client to connect to a Samba server using clear-text authentication, thepassword level must be set to the maximum number of uppercase letters thatcould appear in a password. Note that if the Server OS uses the traditional DES versionof crypt(), a password level of 8 will result in case-insensitive passwords as seenfrom Windows users. This will also result in longer login times because Samba has to compute the permutationsof the password string and try them one by one until a match is located (or all combinations fail).
The best option to adopt is to enable support for encrypted passwords whereverSamba is used. Most attempts to apply the registry change to re-enable plaintextpasswords will eventually lead to user complaints and unhappiness.
We all make mistakes. It is okay to make mistakes, as long as they are made in the right placesand at the right time. A mistake that causes lost productivity is seldom tolerated; however, a mistakemade in a developmental test lab is expected.
Here we look at common mistakes and misapprehensions that have been the subject of discussionson the Samba mailing lists. Many of these are avoidable by doing your homework before attemptinga Samba implementation. Some are the result of a misunderstanding of the English language,which has many phrases that are potentially vague and may be highly confusingto those for whom English is not their native tongue.
To some, the nature of the Samba security mode is obvious, but entirelywrong all the same. It is assumed that security = server means that Sambawill act as a server. Not so! This setting means that Samba will tryto use another SMB server as its source for user authentication alone.
Samba is a server regardless of which security mode is chosen. When Samba is used outside of a domain securitycontext, it is best to leave the security mode at the default setting. By default Samba-3 uses user-modesecurity.
The smb.conf
parameter security = domain does not really make Samba behaveas a domain controller. This setting means we want Samba to be a domain member. See Samba as a PDC for more information.
Guess! So many others do. But whatever you do, do not think that security = usermakes Samba act as a domain member. Read the manufacturer's manual before the warranty expires. See Domain Membership, for more information.
“Why does server_validate() simply give up rather than re-establish its connection to thepassword server? Though I am not fluent in the SMB protocol, perhaps the cluster serverprocess passes along to its client workstation the session key it receives from the passwordserver, which means the password hashes submitted by the client would not work on a subsequentconnection whose session key would be different. So server_validate() must give up.”
Indeed. That's why security = serveris at best a nasty hack. Please use security = domain;security = server mode is also known as pass-through authentication.
“When I try to log in to the DOMAIN, the eventlog shows tried credentials DOMAIN/username; effectivecredentials SERVER/username”
Usually this is due to a user or machine account being created before the Samba server is configured to be adomain controller. Accounts created before the server becomes a domain controller will belocal accounts and authenticated as what looks like a member in the SERVER domain, muchlike local user accounts in Windows 2000 and later. Accounts created after the Samba server becomes a domaincontroller will be domain accounts and will be authenticated as a member of the DOMAINdomain.
This can be verified by issuing the command pdbedit -L -v username
. If this reports DOMAINthen the account is a domain account, if it reports SERVER then the account is a local account.
The easiest way to resolve this is to remove and recreate the account; however this may cause problems withestablished user profiles. You can also use pdbedit -u username -I DOMAIN
. You may alsoneed to change the User SID and Primary Group SID to match the domain.