1 <chapter id="ServerType">
8 <title>Server Types and Security Modes</title>
11 This chapter provides information regarding the types of server that Samba may be
12 configured to be. A Microsoft network administrator who wishes to migrate to or to
13 use Samba will want to know what within a Samba context, terms familiar to MS Windows
14 adminstrator mean. This means that it is essential also to define how critical security
15 modes function BEFORE we get into the details of how to configure the server itself.
19 The chapter provides an overview of the security modes of which Samba is capable
20 and how these relate to MS Windows servers and clients.
24 Firstly we should recognise the question so often asked, "Why would I want to use Samba?"
25 So, in those chapters where the answer may be important you will see a section that highlights
26 features and benefits. These may be for or against Samba.
30 <title>Features and Benefits</title>
33 Two men were walking down a dusty road, when one suddenly kicked up a small red stone. It
34 hurt his toe and lodged in his sandle. He took the stone out and cursed it with a passion
35 and fury fitting his anguish. The other looked at the stone and said, that is a garnet - I
36 can turn that into a precious gem and some day it will make a princess very happy!
40 The moral of this tale: Two men, two very different perspectives regarding the same stone.
41 Like it or not, Samba is like that stone. Treated the right way and it can bring great
42 pleasure, but if you are forced upon it and have no time for it's secrets then it can be
43 a source of discomfort.
47 Samba started out as a project that sought to provide interoperability for MS Windows 3.x
48 clients with a Unix server. It has grown up a lot since it's humble beginnings and now provides
49 features and functionality fit for large scale deployment. It also has some warts. In sections
50 like this one we will tell of both.
54 So now, what are the benefits of features mentioned in this chapter?
59 Samba-3 can replace an MS Windows NT4 Domain Controller
63 Samba-3 offers excellent interoperability with MS Windows NT4
64 style domains as well as natively with Microsoft Active
69 Samba-3 permits full NT4 style Interdomain Trusts
73 Samba has security modes that permit more flexible
74 authentication than is possible with MS Windows NT4 Domain Controllers.
78 Samba-3 permits use of multiple account database backends
82 The account (password) database backends can be distributed
83 and replicated using multiple methods. This gives Samba-3
84 greater flexibility than MS Windows NT4 and in many cases a
85 significantly higher utility than Active Directory domains
93 <title>Server Types</title>
95 <para>Adminstrators of Microsoft networks often refer to there being three
96 different type of servers:</para>
99 <listitem><para>Domain Controller</para>
101 <member>Primary Domain Controller</member>
102 <member>Backup Domain Controller</member>
103 <member>ADS Domain Controller</member>
106 <listitem><para>Domain Member Server</para>
108 <member>Active Directory Member Server</member>
109 <member>NT4 Style Domain Member Server</member>
112 <listitem><para>Stand Alone Server</para></listitem>
116 The chapters covering Domain Control, Backup Domain Control and Domain Membership provide
117 pertinent information regarding Samba-3 configuration for each of these server roles.
118 The reader is strongly encouraged to become intimately familiar with the information
125 <title>Samba Security Modes</title>
128 In this section the function and purpose of Samba's <parameter>security</parameter>
129 modes are described. An acurate understanding of how Samba implements each security
130 mode as well as how to configure MS Windows clients for each mode will significantly
131 reduce user complaints and administrator heartache.
135 There are in the SMB/CIFS networking world only two types of security: <emphasis>USER Level</emphasis>
136 and <emphasis>SHARE Level</emphasis>. We refer to these collectively as <emphasis>security levels</emphasis>. In implementing these two <emphasis>security levels</emphasis> samba provides flexibilities
137 that are not available with Microsoft Windows NT4 / 200x servers. Samba knows of five (5)
138 ways that allow the security levels to be implemented. In actual fact, Samba implements
139 <emphasis>SHARE Level</emphasis> security only one way, but has four ways of implementing
140 <emphasis>USER Level</emphasis> security. Collectively, we call the samba implementations
141 <emphasis>Security Modes</emphasis>. These are: <emphasis>SHARE</emphasis>, <emphasis>USER</emphasis>, <emphasis>DOMAIN</emphasis>,
142 <emphasis>ADS</emphasis>, and <emphasis>SERVER</emphasis>
143 modes. They are documented in this chapter.
147 A SMB server tells the client at startup what <parameter>security level</parameter>
148 it is running. There are two options <emphasis>share level</emphasis> and
149 <emphasis>user level</emphasis>. Which of these two the client receives affects
150 the way the client then tries to authenticate itself. It does not directly affect
151 (to any great extent) the way the Samba server does security. This may sound strange,
152 but it fits in with the client/server approach of SMB. In SMB everything is initiated
153 and controlled by the client, and the server can only tell the client what is
154 available and whether an action is allowed.
158 <title>User Level Security</title>
161 We will describe <parameter>user level</parameter> security first, as its simpler.
162 In <emphasis>user level</emphasis> security the client will send a
163 <emphasis>session setup</emphasis> command directly after the protocol negotiation.
164 This contains a username and password. The server can either accept or reject that
165 username/password combination. Note that at this stage the server has no idea what
166 share the client will eventually try to connect to, so it can't base the
167 <emphasis>accept/reject</emphasis> on anything other than:
171 <listitem><para>The username/password</para></listitem>
172 <listitem><para>The name of the client machine</para></listitem>
176 If the server accepts the username/password then the client expects to be able to
177 mount shares (using a <emphasis>tree connection</emphasis>) without specifying a
178 password. It expects that all access rights will be as the username/password
179 specified in the <emphasis>session setup</emphasis>.
183 It is also possible for a client to send multiple <emphasis>session setup</emphasis>
184 requests. When the server responds it gives the client a <emphasis>uid</emphasis> to use
185 as an authentication tag for that username/password. The client can maintain multiple
186 authentication contexts in this way (WinDD is an example of an application that does this).
190 <title>Example Configuration</title>
193 The &smb.conf; parameter that sets <emphasis>User Level Security</emphasis> is:
196 <para><programlisting>
198 </programlisting></para>
201 This is the default setting since samba-2.2.x.
208 <title>Share Level Security</title>
211 Ok, now for share level security. In share level security the client authenticates
212 itself separately for each share. It will send a password along with each
213 <emphasis>tree connection</emphasis> (share mount). It does not explicitly send a
214 username with this operation. The client is expecting a password to be associated
215 with each share, independent of the user. This means that samba has to work out what
216 username the client probably wants to use. It is never explicitly sent the username.
217 Some commercial SMB servers such as NT actually associate passwords directly with
218 shares in share level security, but samba always uses the unix authentication scheme
219 where it is a username/password pair that is authenticated, not a share/password pair.
223 To gain understanding of the MS Windows networking parallels to this, one should think
224 in terms of MS Windows 9x/Me where one can create a shared folder that provides read-only
225 or full access, with or without a password.
229 Many clients send a <emphasis>session setup</emphasis> even if the server is in share
230 level security. They normally send a valid username but no password. Samba records
231 this username in a list of <emphasis>possible usernames</emphasis>. When the client
232 then does a <emphasis>tree connection</emphasis> it also adds to this list the name
233 of the share they try to connect to (useful for home directories) and any users
234 listed in the <parameter>user =</parameter> &smb.conf; line. The password is then checked
235 in turn against these <emphasis>possible usernames</emphasis>. If a match is found
236 then the client is authenticated as that user.
240 <title>Example Configuration</title>
243 The &smb.conf; parameter that sets <emphasis>Share Level Security</emphasis> is:
246 <para><programlisting>
248 </programlisting></para>
251 Plese note that there are reports that recent MS Widows clients do not like to work
252 with share mode security servers. You are strongly discouraged from use of this parameter.
259 <title>Domain Security Mode (User Level Security)</title>
262 When samba is operating in <parameter>security = domain</parameter> mode this means that
263 the Samba server has a domain security trust account (a machine account) and will cause
264 all authentication requests to be passed through to the domain controllers.
268 <title>Example Configuration</title>
270 Samba as a Domain Member Server
274 This method involves addition of the following parameters in the &smb.conf; file:
277 <para><programlisting>
278 encrypt passwords = Yes
280 workgroup = "name_of_NT_domain"
282 </programlisting></para>
285 The use of the "*" argument to <parameter>password server</parameter> will cause samba to locate the
286 domain controller in a way analogous to the way this is done within MS Windows NT.
287 This is the default behaviour.
291 In order for this method to work the Samba server needs to join the MS Windows NT
292 security domain. This is done as follows:
296 <step><para>On the MS Windows NT domain controller using
297 the Server Manager add a machine account for the Samba server.
300 <step><para>Next, on the Unix/Linux system execute:</para>
302 <para>&rootprompt;<userinput>smbpasswd -r PDC_NAME -j DOMAIN_NAME</userinput> (samba 2.x)</para>
304 <para>&rootprompt;<userinput>net join -U administrator%password</userinput> (samba-3)</para>
309 As of Samba-2.2.4 the Samba 2.2.x series can auto-join a Windows NT4 style Domain just
312 &rootprompt;<userinput>smbpasswd -j <replaceable>DOMAIN_NAME</replaceable> -r <replaceable>PDC_NAME</replaceable> -U Administrator%<replaceable>password</replaceable></userinput>
315 As of Samba-3 the same can be done by executing:
317 &rootprompt;<userinput>net join -U Administrator%<replaceable>password</replaceable></userinput>
319 It is not necessary with Samba-3 to specify the <replaceable>DOMAIN_NAME</replaceable> or the <replaceable>PDC_NAME</replaceable> as it
320 figures this out from the &smb.conf; file settings.
324 Use of this mode of authentication does require there to be a standard Unix account
325 for the user in order to assign a uid once the account has been authenticated by
326 the remote Windows DC. This account can be blocked to prevent logons by clients other than
327 MS Windows through things such as setting an invalid shell in the
328 <filename>/etc/passwd</filename> entry.
332 An alternative to assigning UIDs to Windows users on a Samba member server is
333 presented in the <link linkend="winbind">Winbind Overview</link> chapter
334 in this HOWTO collection.
341 <title>ADS Security Mode (User Level Security)</title>
344 Both Samba 2.2 and 3.0 can join an active directory domain. This is
345 possible even if the domain is run in native mode. Active Directory in
346 native mode perfectly allows NT4-style domain members, contrary to
347 popular belief. The only thing that Active Directory in native mode
348 prohibits is Backup Domain Controllers running NT4.
352 If you are running Active Directory starting with Samba 3.0 you can
353 however join as a native AD member. Why would you want to do that?
354 Your security policy might prohibit the use of NT-compatible
355 authentication protocols. All your machines are running Windows 2000
356 and above and all use full Kerberos. In this case Samba as a NT4-style
357 domain would still require NT-compatible authentication data. Samba in
358 AD-member mode can accept Kerberos.
362 <title>Example Configuration</title>
364 <para><programlisting>
365 realm = your.kerberos.REALM
367 encrypt passwords = Yes
368 </programlisting></para>
371 The following parameter may be required:
374 <para><programlisting>
375 ads server = your.kerberos.server
376 </programlisting></para>
379 Please refer to the Domain Membership section, Active Directory Membership for more information
380 regarding this configuration option.
387 <title>Server Security (User Level Security)</title>
390 Server level security is a left over from the time when Samba was not capable of acting
391 as a domain member server. It is highly recommended NOT to use this feature. Server level
392 security has many draw backs. The draw backs include:
396 <member>Potential Account Lockout on MS Windows NT4/200x password servers</member>
397 <member>Lack of assurance that the password server is the one specified</member>
398 <member>Does not work with Winbind, particularly needed when storing profiles remotely</member>
399 <member>This mode may open connections to the password server, and keep them open for extended periods.</member>
400 <member>Security on the samba server breaks badly when the remote password server suddenly shuts down</member>
401 <member>With this mode there is NO security account in the domain that the password server belongs to for the samba server.</member>
405 In server level security the samba server reports to the client that it is in user level
406 security. The client then does a <emphasis>session setup</emphasis> as described earlier.
407 The samba server takes the username/password that the client sends and attempts to login to the
408 <parameter>password server</parameter> by sending exactly the same username/password that
409 it got from the client. If that server is in user level security and accepts the password
410 then samba accepts the clients connection. This allows the samba server to use another SMB
411 server as the <parameter>password server</parameter>.
415 You should also note that at the very start of all this, where the server tells the client
416 what security level it is in, it also tells the client if it supports encryption. If it
417 does then it supplies the client with a random cryptkey. The client will then send all
418 passwords in encrypted form. Samba supports this type of encryption by default.
422 The parameter <parameter>security = server</parameter> means that Samba reports to clients that
423 it is running in <emphasis>user mode</emphasis> but actually passes off all authentication
424 requests to another <emphasis>user mode</emphasis> server. This requires an additional
425 parameter <parameter>password server</parameter> that points to the real authentication server.
426 That real authentication server can be another Samba server or can be a Windows NT server,
427 the later natively capable of encrypted password support.
431 When Samba is running in <emphasis>server level</emphasis> security it is essential that
432 the parameter <emphasis>password server</emphasis> is set to the precise netbios machine
433 name of the target authentication server. Samba can NOT determine this from NetBIOS name
434 lookups because the choice of the target authentication server arbitrary and can not
435 be determined from a domain name. In essence a samba server that is in
436 <emphasis>server level</emphasis> security is operating in what used to be known as
441 <title>Example Configuration</title>
443 Using MS Windows NT as an authentication server
447 This method involves the additions of the following parameters in the &smb.conf; file:
450 <para><programlisting>
451 encrypt passwords = Yes
453 password server = "NetBIOS_name_of_a_DC"
454 </programlisting></para>
458 There are two ways of identifying whether or not a username and password pair was valid
459 or not. One uses the reply information provided as part of the authentication messaging
460 process, the other uses just an error code.
464 The down-side of this mode of configuration is the fact that for security reasons Samba
465 will send the password server a bogus username and a bogus password and if the remote
466 server fails to reject the username and password pair then an alternative mode of
467 identification of validation is used. Where a site uses password lock out after a
468 certain number of failed authentication attempts this will result in user lockouts.
472 Use of this mode of authentication does require there to be a standard Unix account
473 for the user, this account can be blocked to prevent logons by other than MS Windows clients.
482 <title>Seamless Windows Network Integration</title>
485 MS Windows clients may use encrypted passwords as part of a challenege/response
486 authentication model (a.k.a. NTLMv1 and NTLMv2) or alone, or clear text strings for simple
487 password based authentication. It should be realized that with the SMB protocol
488 the password is passed over the network either in plain text or encrypted, but
489 not both in the same authentication request.
493 When encrypted passwords are used a password that has been entered by the user
494 is encrypted in two ways:
498 <listitem><para>An MD4 hash of the UNICODE of the password
499 string. This is known as the NT hash.
502 <listitem><para>The password is converted to upper case,
503 and then padded or trucated to 14 bytes. This string is
504 then appended with 5 bytes of NULL characters and split to
505 form two 56 bit DES keys to encrypt a "magic" 8 byte value.
506 The resulting 16 bytes for the LanMan hash.
511 MS Windows 95 pre-service pack 1, MS Windows NT versions 3.x and version 4.0
512 pre-service pack 3 will use either mode of password authentication. All
513 versions of MS Windows that follow these versions no longer support plain
514 text passwords by default.
518 MS Windows clients have a habit of dropping network mappings that have been idle
519 for 10 minutes or longer. When the user attempts to use the mapped drive
520 connection that has been dropped, the client re-establishes the connection using
521 a cached copy of the password.
525 When Microsoft changed the default password mode, support was dropped for caching
526 of the plain text password. This means that when the registry parameter is changed
527 to re-enable use of plain text passwords it appears to work, but when a dropped
528 service connection mapping attempts to revalidate it will fail if the remote
529 authentication server does not support encrypted passwords. This means that it
530 is definitely not a good idea to re-enable plain text password support in such clients.
534 The following parameters can be used to work around the issue of Windows 9x client
535 upper casing usernames and password before transmitting them to the SMB server
536 when using clear text authentication.
539 <para><programlisting>
540 <ulink url="smb.conf.5.html#PASSWORDLEVEL">passsword level</ulink> = <replaceable>integer</replaceable>
541 <ulink url="smb.conf.5.html#USERNAMELEVEL">username level</ulink> = <replaceable>integer</replaceable>
542 </programlisting></para>
545 By default Samba will lower case the username before attempting to lookup the user
546 in the database of local system accounts. Because UNIX usernames conventionally
547 only contain lower case character, the <parameter>username level</parameter> parameter
552 However, passwords on UNIX systems often make use of mixed case characters.
553 This means that in order for a user on a Windows 9x client to connect to a Samba
554 server using clear text authentication, the <parameter>password level</parameter>
555 must be set to the maximum number of upper case letter which <emphasis>could</emphasis>
556 appear is a password. Note that the server OS uses the traditional DES version
557 of crypt(), a <parameter>password level</parameter> of 8 will result in case
558 insensitive passwords as seen from Windows users. This will also result in longer
559 login times as Samba has to compute the permutations of the password string and
560 try them one by one until a match is located (or all combinations fail).
564 The best option to adopt is to enable support for encrypted passwords where ever
565 Samba is used. Most attempts to apply the registry change to re-enable plain text
566 passwords will eventually lead to user complaints and unhappiness.
572 <title>Common Errors</title>
575 We all make mistakes. It is Ok to make mistakes, so long as they are made in the right places
576 and at the right time. A mistake that causes lost productivity is seldom tollerated. A mistake
577 made in a developmental test lab is expected.
581 Here we look at common mistakes and misapprehensions that have been the subject of discussions
582 on the samba mailing lists. Many of these are avoidable by doing you homework before attempting
583 a Samba implementation. Some are the result of misundertanding of the English language. The
584 English language has many terms of phrase that are potentially vague and may be highly confusing
585 to those for whom English is not their native tongue.
589 <title>What makes Samba a SERVER?</title>
592 To some the nature of the samba <emphasis>security</emphasis> mode is very obvious, but entirely
593 wrong all the same. It is assumed that <parameter>security = server</parameter> means that Samba
594 will act as a server. Not so! See above - this setting means that samba will <emphasis>try</emphasis>
595 to use another SMB server as it's source of user authentication alone.
601 <title>What makes Samba a Domain Controller?</title>
604 The &smb.conf; parameter <parameter>security = domain</parameter> does NOT really make Samba behave
605 as a Domain Controller! This setting means we want samba to be a domain member!
611 <title>What makes Samba a Domain Member?</title>
614 Guess! So many others do. But whatever you do, do NOT think that <parameter>security = user</parameter>
615 makes Samba act as a domain member. Read the manufacturers manual before the warranty expires!
622 <title>Constantly Losing Connections to Password Server</title>
625 Why does server_validate() simply give up rather than re-establishing its connection to the
626 password server? Though I am not fluent in the SMB protocol, perhaps the cluster server
627 process passes along to its client workstation the session key it receives from the password
628 server, which means the password hashes submitted by the client would not work on a subsequent
629 connection, whose session key would be different. So server_validate() must give up.
633 Indeed. That's why security = server is at best a nasty hack. Please use security = domain.
634 <parameter>security = server</parameter> mode is also known as pass-through authentication.