~ubuntu-branches/ubuntu/raring/ubuntu-docs/raring

« back to all changes in this revision

Viewing changes to serverguide/C/windows-networking.xml

  • Committer: Bazaar Package Importer
  • Author(s): Matthew East
  • Date: 2010-09-19 11:35:42 UTC
  • Revision ID: james.westby@ubuntu.com-20100919113542-mbxqe7yuo4ggnrw3
Tags: 10.10.3
* Amend font-family for browser startpage (LP: #195590)
* Add translations from Launchpad

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<?xml version="1.0" encoding="UTF-8"?>
2
 
<!DOCTYPE chapter PUBLIC "-//OASIS//DTD DocBook XML V4.3//EN" 
3
 
        "http://www.oasis-open.org/docbook/xml/4.3/docbookx.dtd" [
4
 
<!ENTITY % globalent SYSTEM "../../libs/global.ent">
5
 
%globalent;
6
 
<!ENTITY % gnome-menus-C SYSTEM "../../libs/gnome-menus-C.ent">
7
 
%gnome-menus-C;
8
 
<!ENTITY % xinclude SYSTEM "../../libs/xinclude.mod">
9
 
%xinclude;
10
 
<!ENTITY language "&EnglishAmerican;">
11
 
]>
12
 
<chapter id="windows-networking" status="review">
13
 
  <title>Windows Networking</title>
14
 
  
15
 
  <para>
16
 
  Computer networks are often comprised of diverse systems, and while operating a network
17
 
  made up entirely of Ubuntu desktop and server computers would certainly be fun, some network environments
18
 
  must consist of both Ubuntu and <trademark class='registered'>Microsoft</trademark> 
19
 
  <trademark class='registered'>Windows</trademark> systems working together in harmony.  
20
 
  This section of the &ubuntu; &sg-title; introduces principles and tools used in 
21
 
  configuring your Ubuntu Server for sharing network resources with Windows computers.
22
 
  </para>
23
 
 
24
 
  <sect1 id="windows-networking-introduction" status="review">
25
 
    <title>Introduction</title>
26
 
    
27
 
    <para>
28
 
    Successfully networking your Ubuntu system with Windows clients involves providing and integrating with services 
29
 
    common to Windows environments. Such services assist the sharing of data and information about the computers 
30
 
    and users involved in the network, and may be classified under three major categories of functionality:
31
 
    </para>
32
 
    
33
 
    <itemizedlist>
34
 
      <listitem>
35
 
        <para>
36
 
        <emphasis role="bold">File and Printer Sharing Services</emphasis>. Using the Server Message Block (SMB) 
37
 
        protocol to facilitate the sharing of files, folders, volumes, and the sharing of printers throughout the network.
38
 
        </para>
39
 
      </listitem>
40
 
      <listitem>
41
 
        <para>
42
 
        <emphasis role="bold">Directory Services</emphasis>. Sharing vital information about the computers and users of 
43
 
        the network with such technologies as the Lightweight Directory Access Protocol (LDAP) and Microsoft
44
 
        <trademark class='registered'>Active Directory</trademark>.
45
 
        </para>
46
 
      </listitem>
47
 
      <listitem>
48
 
        <para>
49
 
        <emphasis role="bold">Authentication and Access</emphasis>. Establishing the identity of a computer or user of 
50
 
        the network and determining the information the computer or user is authorized to access using such principles 
51
 
        and technologies as file permissions, group policies, and the Kerberos authentication service.
52
 
        </para>
53
 
      </listitem>
54
 
      </itemizedlist>
55
 
        
56
 
      <para>
57
 
      Fortunately, your Ubuntu system may provide all such facilities to Windows clients and share network resources 
58
 
      among them.  One of the principal pieces of software your Ubuntu system includes for Windows networking is the Samba 
59
 
      suite of SMB server applications and tools.  
60
 
      </para>
61
 
        
62
 
      <para>
63
 
      This section of the &ubuntu; &sg-title; will introduce some of the common Samba use cases, and how to 
64
 
      install and configure the necessary packages.  Additional detailed documentation and information on Samba can be found
65
 
      on the <ulink url="http://www.samba.org">Samba website</ulink>.
66
 
      </para>
67
 
  
68
 
  </sect1>
69
 
  <sect1 id="samba-fileserver" status="review">
70
 
    <title>Samba File Server</title>
71
 
    
72
 
    <para>
73
 
    One of the most common ways to network Ubuntu and Windows computers is to configure Samba as a File Server.  This section 
74
 
    covers setting up a <application>Samba</application> server to share files with Windows clients.
75
 
    </para>
76
 
 
77
 
    <para>
78
 
    The server will be configured to share files with any client on the network without prompting for a password.  If
79
 
    your environment requires stricter Access Controls see <xref linkend="samba-fileprint-security"/>
80
 
    </para>
81
 
 
82
 
    <sect2 id="samba-fileserver-installation" status="review">
83
 
      <title>Installation</title>
84
 
 
85
 
      <para>
86
 
      The first step is to install the <application>samba</application> package.  From a terminal prompt enter:
87
 
      </para>
88
 
 
89
 
<screen>
90
 
<command>sudo apt-get install samba</command>
91
 
</screen>
92
 
    
93
 
      <para>
94
 
      That's all there is to it; you are now ready to configure Samba to share files.
95
 
      </para>
96
 
 
97
 
    </sect2>
98
 
    <sect2 id="samba-fileserver-configuration" status="review">
99
 
      <title>Configuration</title>
100
 
    
101
 
      <para>
102
 
      The main Samba configuration file is located in <filename>/etc/samba/smb.conf</filename>.  The default configuration file
103
 
      has a significant amount of comments in order to document various configuration directives.  
104
 
      </para>
105
 
      <note>
106
 
        <para>
107
 
        Not all the available options are included in the default configuration file.  See the <filename>smb.conf</filename>
108
 
        <application>man</application> page or the 
109
 
        <ulink url="http://samba.org/samba/docs/man/Samba-HOWTO-Collection/">Samba HOWTO Collection</ulink> for more details.
110
 
        </para>
111
 
      </note>
112
 
 
113
 
      <procedure>        
114
 
        <step>
115
 
 
116
 
        <para>
117
 
        First, edit the following key/value pairs in the <emphasis>[global]</emphasis> section of 
118
 
        <filename>/etc/samba/smb.conf</filename>:
119
 
        </para>
120
 
 
121
 
<programlisting>
122
 
   workgroup = EXAMPLE
123
 
   ...
124
 
   security = user
125
 
</programlisting>
126
 
 
127
 
        <para>
128
 
        The <emphasis>security</emphasis> parameter is farther down in the [global] section, and is commented by default.
129
 
        Also, change <emphasis>EXAMPLE</emphasis> to better match your environment.  
130
 
        </para>
131
 
 
132
 
        </step>
133
 
        <step>
134
 
  
135
 
        <para>
136
 
        Create a new section at the bottom of the file, or uncomment one of the examples, for the directory to be shared:
137
 
        </para>
138
 
 
139
 
<programlisting>
140
 
[share]
141
 
    comment = Ubuntu File Server Share
142
 
    path = /srv/samba/share
143
 
    browsable = yes
144
 
    guest ok = yes
145
 
    read only = no
146
 
    create mask = 0755
147
 
</programlisting>
148
 
 
149
 
      <itemizedlist>
150
 
        <listitem>
151
 
          <para>
152
 
          <emphasis>comment:</emphasis> a short description of the share.  Adjust to fit your needs.
153
 
          </para>
154
 
        </listitem>
155
 
        <listitem>
156
 
          <para>
157
 
          <emphasis>path:</emphasis> the path to the directory to share. 
158
 
          </para>
159
 
          <para>
160
 
          This example uses <filename>/srv/samba/sharename</filename> because, according to the 
161
 
          <emphasis>Filesystem Hierarchy Standard (FHS)</emphasis>, 
162
 
          <ulink url="http://www.pathname.com/fhs/pub/fhs-2.3.html#SRVDATAFORSERVICESPROVIDEDBYSYSTEM">/srv</ulink>
163
 
          is where site-specific data should be served.  Technically Samba shares can be placed anywhere on the filesystem
164
 
          as long as the permissions are correct, but adhering to standards is recommended.
165
 
          </para>
166
 
        </listitem>
167
 
        <listitem>
168
 
          <para>
169
 
          <emphasis>browsable:</emphasis> enables Windows clients to browse the shared directory using 
170
 
          <application>Windows Explorer</application>.
171
 
          </para>
172
 
        </listitem>
173
 
        <listitem>
174
 
          <para>
175
 
          <emphasis>guest ok:</emphasis> allows clients to connect to the share without supplying a password.
176
 
          </para>
177
 
        </listitem>
178
 
        <listitem>
179
 
          <para>
180
 
          <emphasis>read only:</emphasis> determines if the share is read only or if write privileges are granted.  Write privileges are allowed only when the value is <emphasis>no</emphasis>, as is seen in this example.  If the value is <emphasis>yes</emphasis>, then access to the share is read only.
181
 
          </para>
182
 
        </listitem>
183
 
        <listitem>
184
 
          <para>
185
 
          <emphasis>create mask:</emphasis> determines the permissions new files will have when created.
186
 
          </para>
187
 
        </listitem>
188
 
      </itemizedlist>
189
 
 
190
 
      </step>
191
 
      <step>
192
 
        
193
 
        <para> 
194
 
        Now that <application>Samba</application> is configured, the directory needs to be created and the permissions
195
 
        changed.  From a terminal enter:
196
 
        </para>
197
 
 
198
 
<screen>
199
 
<command>sudo mkdir -p /srv/samba/share</command>
200
 
<command>sudo chown nobody.nogroup /srv/samba/share/</command>
201
 
</screen>
202
 
 
203
 
      <note>
204
 
        <para>
205
 
        The <emphasis>-p</emphasis> switch tells mkdir to create the entire directory tree if it doesn't exist.
206
 
        </para>
207
 
      </note>
208
 
 
209
 
      </step>
210
 
      <step>
211
 
     
212
 
      <para>
213
 
      Finally, restart the <application>samba</application> services to enable the new configuration:
214
 
      </para>
215
 
 
216
 
<screen>
217
 
<command>sudo restart smbd</command>
218
 
<command>sudo restart nmbd</command>
219
 
</screen>
220
 
 
221
 
      </step>
222
 
      </procedure>
223
 
 
224
 
      <warning>
225
 
        <para>
226
 
        Once again, the above configuration gives all access to any client on the local network.  For a more secure
227
 
        configuration see <xref linkend="samba-fileprint-security"/>.
228
 
        </para>
229
 
      </warning>
230
 
 
231
 
      <para>
232
 
      From a Windows client you should now be able to browse to the Ubuntu file server and see the shared directory.  To 
233
 
      check that everything is working try creating a directory from Windows. 
234
 
      </para>
235
 
 
236
 
      <para>
237
 
      To create additional shares simply create new <emphasis>[dir]</emphasis> sections in 
238
 
      <filename>/etc/samba/smb.conf</filename>, and restart <emphasis>Samba</emphasis>.  Just make sure that the directory
239
 
      you want to share actually exists and the permissions are correct.
240
 
      </para>
241
 
 
242
 
      <note>
243
 
        <para>
244
 
        The file share named <emphasis>"[share]"</emphasis> and the path <filename>/srv/samba/share</filename> are just examples.
245
 
        Adjust the share and path names to fit your environment.  It is a good idea to name a share after a directory on the 
246
 
        file system.  Another example would be a share name of <emphasis>[qa]</emphasis> with a path of <filename>/srv/samba/qa</filename>.
247
 
        </para>
248
 
      </note>
249
 
 
250
 
    </sect2>
251
 
    <sect2 id="samba-fileserver-resources" status="review">
252
 
      <title>Resources</title>
253
 
 
254
 
      <itemizedlist>
255
 
        <listitem>
256
 
          <para>
257
 
          For in depth Samba configurations see the 
258
 
          <ulink url="http://samba.org/samba/docs/man/Samba-HOWTO-Collection/">Samba HOWTO Collection</ulink>
259
 
          </para>
260
 
        </listitem>
261
 
        <listitem>
262
 
          <para>
263
 
          The guide is also available in 
264
 
          <ulink url="http://www.amazon.com/exec/obidos/tg/detail/-/0131882228">printed format</ulink>.
265
 
          </para>
266
 
        </listitem>
267
 
        <listitem>
268
 
          <para>
269
 
          O'Reilly's <ulink url="http://www.oreilly.com/catalog/9780596007690/">Using Samba</ulink> is another good
270
 
          reference.
271
 
          </para>
272
 
        </listitem>
273
 
        <listitem>
274
 
          <para>
275
 
          The <ulink url="https://help.ubuntu.com/community/Samba">Ubuntu Wiki Samba </ulink> page.
276
 
          </para>
277
 
        </listitem>
278
 
      </itemizedlist>
279
 
   
280
 
    </sect2>
281
 
  </sect1>
282
 
  <sect1 id="samba-printserver" status="review">
283
 
    <title>Samba Print Server</title>
284
 
    
285
 
    <para>
286
 
    Another common use of Samba is to configure it to share printers installed, either locally or over the network, on 
287
 
    an Ubuntu server.  Similar to <xref linkend="samba-fileserver"/> this section will configure Samba to allow any client
288
 
    on the local network to use the installed printers without prompting for a username and password.
289
 
    </para>
290
 
 
291
 
    <para>
292
 
    For a more secure configuration see <xref linkend="samba-fileprint-security"/>.
293
 
    </para>
294
 
 
295
 
    <sect2 id="samba-printserver-installation" status="review">
296
 
      <title>Installation</title>
297
 
 
298
 
      <para>
299
 
      Before installing and configuring Samba it is best to already have a working <application>CUPS</application> 
300
 
      installation. See <xref linkend="cups"/> for details.
301
 
      </para>
302
 
 
303
 
      <para>
304
 
      To install the <application>samba</application> package, from a terminal enter:
305
 
      </para>
306
 
 
307
 
<screen>
308
 
<command>sudo apt-get install samba</command>
309
 
</screen>
310
 
 
311
 
    </sect2>
312
 
    <sect2 id="samba-printserver-configuration" status="review">
313
 
      <title>Configuration</title>
314
 
    <para>
315
 
    After installing samba edit <filename>/etc/samba/smb.conf</filename>.  Change the <emphasis>workgroup</emphasis> 
316
 
    attribute to what is appropriate for your network, and change <emphasis>security</emphasis> to 
317
 
    <emphasis role="italic">share</emphasis>:
318
 
    </para>
319
 
 
320
 
<programlisting>
321
 
   workgroup = EXAMPLE
322
 
   ...
323
 
   security = user
324
 
</programlisting>
325
 
 
326
 
    <para>
327
 
    In the <emphasis>[printers]</emphasis> section change the <emphasis>guest ok</emphasis> option to <emphasis role="italic">yes</emphasis>:
328
 
    </para>
329
 
 
330
 
<programlisting>
331
 
   browsable = yes
332
 
   guest ok = yes
333
 
</programlisting>
334
 
 
335
 
    <para>
336
 
    After editing <filename>smb.conf</filename> restart Samba:
337
 
    </para>
338
 
 
339
 
<screen>
340
 
<command>sudo restart smbd</command>
341
 
<command>sudo restart nmbd</command>
342
 
</screen>
343
 
 
344
 
    <para>
345
 
    The default Samba configuration will automatically share any printers installed.  Simply install the printer locally 
346
 
    on your Windows clients.
347
 
    </para>
348
 
    
349
 
    </sect2>
350
 
    <sect2 id="samba-printserver-resources" status="review">
351
 
      <title>Resources</title>
352
 
 
353
 
      <itemizedlist>
354
 
        <listitem>
355
 
          <para>
356
 
          For in depth Samba configurations see the 
357
 
          <ulink url="http://samba.org/samba/docs/man/Samba-HOWTO-Collection/">Samba HOWTO Collection</ulink>
358
 
          </para>
359
 
        </listitem>
360
 
        <listitem>
361
 
          <para>
362
 
          The guide is also available in 
363
 
          <ulink url="http://www.amazon.com/exec/obidos/tg/detail/-/0131882228">printed format</ulink>.
364
 
          </para>
365
 
        </listitem>
366
 
        <listitem>
367
 
          <para>
368
 
          O'Reilly's <ulink url="http://www.oreilly.com/catalog/9780596007690/">Using Samba</ulink> is another good
369
 
          reference.
370
 
          </para>
371
 
        </listitem>
372
 
        <listitem>
373
 
          <para>
374
 
          Also, see the <ulink url="http://www.cups.org/">CUPS Website</ulink> for more information on configuring CUPS.
375
 
          </para>
376
 
        </listitem>
377
 
        <listitem>
378
 
          <para>
379
 
          The <ulink url="https://help.ubuntu.com/community/Samba">Ubuntu Wiki Samba </ulink> page.
380
 
          </para>
381
 
        </listitem>
382
 
      </itemizedlist>
383
 
   
384
 
    </sect2>
385
 
  </sect1>
386
 
  <sect1 id="samba-fileprint-security" status="review">
387
 
    <title>Securing a Samba File and Print Server</title>
388
 
 
389
 
    <sect2 id="samba-security-mode" status="review">
390
 
      <title>Samba Security Modes</title>
391
 
 
392
 
      <para>
393
 
      There are two security levels available to the Common Internet Filesystem (CIFS) network protocol 
394
 
      <emphasis>user-level</emphasis> and <emphasis>share-level</emphasis>.  Samba's <emphasis>security mode</emphasis>
395
 
      implementation allows more flexibility, providing four ways of implementing user-level security and one way to 
396
 
      implement share-level:
397
 
      </para>
398
 
      
399
 
      <itemizedlist>
400
 
        <listitem>
401
 
          <para>
402
 
          <emphasis>security = user:</emphasis> requires clients to supply a username and password to connect to shares. 
403
 
          Samba user accounts are separate from system accounts, but the <application>libpam-smbpass</application> 
404
 
          package will sync system users and passwords with the Samba user database.
405
 
          </para>
406
 
        </listitem>
407
 
        <listitem>
408
 
          <para>
409
 
          <emphasis>security = domain:</emphasis> this mode allows the Samba server to appear to Windows clients as a Primary
410
 
          Domain Controller (PDC), Backup Domain Controller (BDC), or a Domain Member Server (DMS).  See 
411
 
          <xref linkend="samba-dc"/> for further information.
412
 
          </para>
413
 
        </listitem>
414
 
        <listitem>
415
 
          <para>
416
 
          <emphasis>security = ADS:</emphasis> allows the Samba server to join an Active Directory domain as a native
417
 
          member.  See <xref linkend="samba-ad-integration"/> for details.
418
 
          </para>
419
 
        </listitem>
420
 
        <listitem>
421
 
          <para>
422
 
          <emphasis>security = server:</emphasis> this mode is left over from before Samba could become a member server, and 
423
 
          due to some security issues should not be used.  See the 
424
 
          <ulink url="http://samba.org/samba/docs/man/Samba-HOWTO-Collection/ServerType.html#id349531">Server Security</ulink>
425
 
          section of the Samba guide for more details.
426
 
          </para>
427
 
        </listitem>
428
 
        <listitem>
429
 
          <para>
430
 
          <emphasis>security = share:</emphasis> allows clients to connect to shares without supplying a username and 
431
 
          password.
432
 
          </para>
433
 
        </listitem>
434
 
      </itemizedlist>
435
 
 
436
 
      <para>
437
 
      The security mode you choose will depend on your environment and what you need the Samba server to accomplish.
438
 
      </para>
439
 
 
440
 
    </sect2>
441
 
    <sect2 id="samba-user-security" status="review">
442
 
      <title>Security = User</title>
443
 
 
444
 
      <para>
445
 
      This section will reconfigure the Samba file and print server, from <xref linkend="samba-fileserver"/> and
446
 
      <xref linkend="samba-printserver"/>, to require authentication.
447
 
      </para>
448
 
 
449
 
      <para>
450
 
      First, install the <application>libpam-smbpass</application> package which will sync the system users to the Samba
451
 
      user database:
452
 
      </para>
453
 
 
454
 
<screen>
455
 
<command>sudo apt-get install libpam-smbpass</command>
456
 
</screen>
457
 
 
458
 
      <note>
459
 
        <para>
460
 
        If you chose the <emphasis>Samba Server</emphasis> task during installation <application>libpam-smbpass</application>
461
 
        is already installed.
462
 
        </para>
463
 
      </note>
464
 
 
465
 
      <para>
466
 
      Edit <filename>/etc/samba/smb.conf</filename>, and in the <emphasis>[share]</emphasis> section change:
467
 
      </para>
468
 
 
469
 
<programlisting>
470
 
    guest ok = no
471
 
</programlisting>
472
 
 
473
 
      <para>
474
 
      Finally, restart Samba for the new settings to take effect:
475
 
      </para>
476
 
 
477
 
<screen>
478
 
<command>sudo restart smbd</command>
479
 
<command>sudo restart nmbd</command>
480
 
</screen>
481
 
 
482
 
      <para>
483
 
      Now when connecting to the shared directories or printers you should be prompted for a username and password.  
484
 
      </para>
485
 
 
486
 
      <note>
487
 
        <para>
488
 
        If you choose to map a network drive to the share you can check the <quote>Reconnect at Logon</quote> check 
489
 
        box, which will require you to only enter the username and password once, at least until the password changes.
490
 
        </para>
491
 
      </note>
492
 
 
493
 
    </sect2>
494
 
    <sect2 id="samba-share-security" status="review">
495
 
      <title>Share Security</title>
496
 
 
497
 
      <para>
498
 
      There are several options available to increase the security for each individual shared directory.  Using the 
499
 
      <emphasis>[share]</emphasis> example, this section will cover some common options.
500
 
      </para>
501
 
 
502
 
      <sect3 id="windows-networking-groups" status="review">
503
 
        <title>Groups</title>
504
 
        
505
 
        <para>
506
 
        Groups define a collection of computers or users which have a common level of access to particular network 
507
 
        resources and offer a level of granularity in controlling access to such resources.  For example, if a group 
508
 
        <emphasis role="italic">qa</emphasis> is defined and contains the users <emphasis role="italic">freda</emphasis>,
509
 
        <emphasis role="italic">danika</emphasis>, and <emphasis role="italic">rob</emphasis> and a second group
510
 
        <emphasis role="italic">support</emphasis> is defined and consists of users <emphasis role="italic">danika</emphasis>,
511
 
        <emphasis role="italic">jeremy</emphasis>, and <emphasis role="italic">vincent</emphasis> then certain network 
512
 
        resources configured to allow access by the <emphasis role="italic">qa</emphasis> group will subsequently enable 
513
 
        access by freda, danika, and rob, but not jeremy or vincent.  Since the user <emphasis role="italic">danika</emphasis>
514
 
        belongs to both the <emphasis role="italic">qa</emphasis> and <emphasis role="italic">support</emphasis> groups, she
515
 
        will be able to access resources configured for access by both groups, whereas all other users will have only access 
516
 
        to resources explicitly allowing the group they are part of.
517
 
        </para>
518
 
 
519
 
        <para>
520
 
        By default Samba looks for the local system groups defined in <filename>/etc/group</filename> to determine which users
521
 
        belong to which groups.  For more information on adding and removing users from groups see 
522
 
        <xref linkend="adding-deleting-users"/>.
523
 
        </para>
524
 
 
525
 
        <para>
526
 
        When defining groups in the Samba configuration file, <filename>/etc/samba/smb.conf</filename>, the recognized syntax 
527
 
        is to preface the group name with an "@" symbol.  For example, if you wished to define a group named 
528
 
        <emphasis role="italic">sysadmin</emphasis> in a certain section of the <filename>/etc/samba/smb.conf</filename>, 
529
 
        you would do so by entering the group name as <emphasis role="bold">@sysadmin</emphasis>.
530
 
        </para>
531
 
 
532
 
      </sect3>
533
 
      <sect3 id="samba-file-permissions" status="review">
534
 
        <title>File Permissions</title>
535
 
 
536
 
        <para>
537
 
        File Permissions define the explicit rights a computer or user has to a particular directory, file, or set of
538
 
        files.  Such permissions may be defined by editing the <filename>/etc/samba/smb.conf</filename> file and specifying
539
 
        the explicit permissions of a defined file share.
540
 
        </para>
541
 
 
542
 
        <para>
543
 
        For example, if you have defined a Samba share called <emphasis>share</emphasis> and wish to give 
544
 
        <emphasis role="italic">read-only</emphasis> permissions to the group of users known as 
545
 
        <emphasis role="italic">qa</emphasis>, but wanted to allow writing to the share by the group called 
546
 
        <emphasis role="italic">sysadmin</emphasis> and the user named <emphasis role="italic">vincent</emphasis>, 
547
 
        then you could edit the <filename>/etc/samba/smb.conf</filename> file, and add the following entries under 
548
 
        the <emphasis>[share]</emphasis> entry:
549
 
        </para>
550
 
 
551
 
<programlisting>
552
 
    read list = @qa
553
 
    write list = @sysadmin, vincent
554
 
</programlisting>
555
 
 
556
 
        <para>
557
 
        Another possible Samba permission is to declare <emphasis>administrative</emphasis> permissions to a
558
 
        particular shared resource.  Users having administrative permissions may read, write, or modify any information
559
 
        contained in the resource the user has been given explicit administrative permissions to.
560
 
        </para>
561
 
 
562
 
        <para>
563
 
        For example, if you wanted to give the user <emphasis role="italic">melissa</emphasis> administrative permissions to
564
 
        the <emphasis role="italic">share</emphasis> example, you would edit the 
565
 
        <filename>/etc/samba/smb.conf</filename> file, and add the following line under the 
566
 
        <emphasis>[share]</emphasis> entry:
567
 
        </para>
568
 
 
569
 
<programlisting>
570
 
    admin users = melissa
571
 
</programlisting>
572
 
 
573
 
        <para>
574
 
        After editing <filename>/etc/samba/smb.conf</filename>, restart Samba for the changes to take effect:
575
 
        </para>
576
 
 
577
 
<screen>
578
 
<command>sudo restart smbd</command>
579
 
<command>sudo restart nmbd</command>
580
 
</screen>
581
 
 
582
 
        <note>
583
 
          <para>
584
 
          For the <emphasis>read list</emphasis> and <emphasis>write list</emphasis> to work the Samba security mode
585
 
          must <emphasis>not</emphasis> be set to <emphasis role="italic">security = share</emphasis>
586
 
          </para>
587
 
        </note> 
588
 
 
589
 
        <para>
590
 
        Now that Samba has been configured to limit which groups have access to the shared directory, the filesystem permissions
591
 
        need to be updated.
592
 
        </para>
593
 
 
594
 
        <para>
595
 
        Traditional Linux file permissions do not map well to Windows NT Access Control Lists (ACLs).  Fortunately POSIX ACLs
596
 
        are available on Ubuntu servers providing more fine grained control.  For example, to enable ACLs on  
597
 
        <filename>/srv</filename> an EXT3 filesystem, edit <filename>/etc/fstab</filename> adding the 
598
 
        <emphasis>acl</emphasis> option:
599
 
        </para>
600
 
 
601
 
<programlisting>
602
 
UUID=66bcdd2e-8861-4fb0-b7e4-e61c569fe17d /srv  ext3    noatime,relatime,acl 0       1
603
 
</programlisting>
604
 
 
605
 
        <para>
606
 
        Then remount the partition:
607
 
        </para>
608
 
 
609
 
<screen>
610
 
<command>sudo mount -v -o remount /srv</command>
611
 
</screen>
612
 
 
613
 
        <note>
614
 
          <para>
615
 
          The above example assumes <filename>/srv</filename> on a separate partition.  If <filename>/srv</filename>,
616
 
          or wherever you have configured your share path, is part of the <filename>/</filename> partition a reboot may be 
617
 
          required.
618
 
          </para>
619
 
        </note>
620
 
 
621
 
        <para>
622
 
        To match the Samba configuration above the <emphasis>sysadmin</emphasis> group will be given read, write, and execute
623
 
        permissions to <filename>/srv/samba/share</filename>, the <emphasis>qa</emphasis> group will be given read and execute
624
 
        permissions, and the files will be owned by the username <emphasis>melissa</emphasis>.  Enter the following in a 
625
 
        terminal:
626
 
        </para>
627
 
 
628
 
<screen>
629
 
<command>sudo chown -R melissa /srv/samba/share/</command>
630
 
<command>sudo chgrp -R sysadmin /srv/samba/share/</command>
631
 
<command>sudo setfacl -R -m g:qa:rx /srv/samba/share/</command>
632
 
</screen>
633
 
 
634
 
        <note>
635
 
          <para>
636
 
          The <application>setfacl</application> command above gives <emphasis>execute</emphasis> permissions to all files in
637
 
          the <filename>/srv/samba/share</filename> directory, which you may or may not want.
638
 
          </para>
639
 
        </note>
640
 
        
641
 
        <para>
642
 
        Now from a Windows client you should notice the new file permissions are implemented.  See the 
643
 
        <application>acl</application> and <application>setfacl</application> man pages for more information on POSIX ACLs.
644
 
        </para>
645
 
 
646
 
      </sect3>
647
 
    </sect2>
648
 
    <sect2 id="samba-apparmor" status="review">
649
 
      <title>Samba AppArmor Profile</title>
650
 
     
651
 
      <para>
652
 
      Ubuntu comes with the <application>AppArmor</application> security module, which provides mandatory access controls.
653
 
      The default AppArmor profile for Samba will need to be adapted to your configuration.  For more details on using
654
 
      AppArmor see <xref linkend="apparmor"/>.
655
 
      </para>
656
 
 
657
 
      <para>
658
 
      There are default AppArmor profiles for <filename>/usr/sbin/smbd</filename> and <filename>/usr/sbin/nmbd</filename>, the
659
 
      Samba daemon binaries, as part of the <application>apparmor-profiles</application> packages.  To install the package,
660
 
      from a terminal prompt enter:
661
 
      </para>
662
 
 
663
 
<screen>
664
 
<command>sudo apt-get install apparmor-profiles</command>
665
 
</screen>
666
 
 
667
 
      <note>
668
 
        <para>
669
 
        This package contains profiles for several other binaries.
670
 
        </para>
671
 
      </note>
672
 
 
673
 
      <para>
674
 
      By default the profiles for <application>smbd</application> and <application>nmbd</application> are in 
675
 
      <emphasis>complain</emphasis> mode allowing Samba to work without modifying the profile, and only logging errors.
676
 
      To place the <application>smbd</application> profile into <emphasis>enforce</emphasis> mode, and have Samba work as 
677
 
      expected, the profile will need to be modified to reflect any directories that are shared.
678
 
      </para>
679
 
 
680
 
      <para>
681
 
      Edit <filename>/etc/apparmor.d/usr.sbin.smbd</filename> adding information for <emphasis>[share]</emphasis> from the
682
 
      file server example:
683
 
      </para>
684
 
 
685
 
<programlisting>
686
 
  /srv/samba/share/ r,
687
 
  /srv/samba/share/** rwkix,
688
 
</programlisting>
689
 
 
690
 
      <para>
691
 
      Now place the profile into <emphasis>enforce</emphasis> and reload it:
692
 
      </para>
693
 
 
694
 
<screen>
695
 
<command>sudo aa-enforce /usr/sbin/smbd</command>
696
 
<command>cat /etc/apparmor.d/usr.sbin.smbd | sudo apparmor_parser -r</command>
697
 
</screen>
698
 
 
699
 
      <para>
700
 
      You should now be able to read, write, and execute files in the shared directory as normal, and the
701
 
      <application>smbd</application> binary will have access to only the configured files and directories.  
702
 
      Be sure to add entries for each directory you configure Samba to share.  Also, any errors will be logged
703
 
      to <filename>/var/log/syslog</filename>.  
704
 
      </para>
705
 
 
706
 
    </sect2>
707
 
    <sect2 id="samba-security-resources" status="review">
708
 
      <title>Resources</title>
709
 
 
710
 
      <itemizedlist>
711
 
        <listitem>
712
 
          <para>
713
 
          For in depth Samba configurations see the 
714
 
          <ulink url="http://samba.org/samba/docs/man/Samba-HOWTO-Collection/">Samba HOWTO Collection</ulink>
715
 
          </para>
716
 
        </listitem>
717
 
        <listitem>
718
 
          <para>
719
 
          The guide is also available in 
720
 
          <ulink url="http://www.amazon.com/exec/obidos/tg/detail/-/0131882228">printed format</ulink>.
721
 
          </para>
722
 
        </listitem>
723
 
        <listitem>
724
 
          <para>
725
 
          O'Reilly's <ulink url="http://www.oreilly.com/catalog/9780596007690/">Using Samba</ulink> is also a good
726
 
          reference.
727
 
          </para>
728
 
        </listitem>
729
 
        <listitem>
730
 
          <para>
731
 
          <ulink url="http://samba.org/samba/docs/man/Samba-HOWTO-Collection/securing-samba.html">Chapter 18</ulink> 
732
 
          of the Samba HOWTO Collection is devoted to security.
733
 
          </para>
734
 
        </listitem>
735
 
        <listitem>
736
 
          <para>
737
 
          For more information on Samba and ACLs see the
738
 
          <ulink url="http://samba.org/samba/docs/man/Samba-HOWTO-Collection/AccessControls.html#id397568">Samba ACLs page
739
 
          </ulink>.
740
 
          </para>
741
 
        </listitem>
742
 
        <listitem>
743
 
          <para>
744
 
          The <ulink url="https://help.ubuntu.com/community/Samba">Ubuntu Wiki Samba </ulink> page.
745
 
          </para>
746
 
        </listitem>
747
 
      </itemizedlist>
748
 
   
749
 
    </sect2>
750
 
  </sect1>
751
 
  <sect1 id="samba-dc" status="review">
752
 
    <title>Samba as a Domain Controller</title>
753
 
    
754
 
    <para>
755
 
    Although it cannot act as an Active Directory Primary Domain Controller (PDC), a Samba server can be configured to
756
 
    appear as a Windows NT4-style domain controller.  A major advantage of this configuration is the ability to centralize 
757
 
    user and machine credentials.  Samba can also use multiple backends to store the user information.
758
 
    </para>
759
 
 
760
 
    <sect2 id="samba-pdc-smbpasswd" status="review">
761
 
      <title>Primary Domain Controller</title>
762
 
 
763
 
      <para>
764
 
      This section covers configuring Samba as a Primary Domain Controller (PDC) using the default smbpasswd backend.
765
 
      </para> 
766
 
 
767
 
      <procedure>
768
 
        <step>
769
 
 
770
 
          <para>
771
 
          First, install Samba, and <application>libpam-smbpass</application> to sync the user accounts,
772
 
          by entering the following in a terminal prompt:
773
 
          </para>
774
 
 
775
 
<screen>
776
 
<command>sudo apt-get install samba libpam-smbpass</command>
777
 
</screen>
778
 
        
779
 
        </step>
780
 
        <step>
781
 
 
782
 
          <para>
783
 
          Next, configure Samba by editing <filename>/etc/samba/smb.conf</filename>. 
784
 
          The <emphasis>security</emphasis> mode should be set to <emphasis role="italic">user</emphasis>, and
785
 
          the <emphasis>workgroup</emphasis> should relate to your organization:
786
 
          </para>
787
 
 
788
 
<programlisting>
789
 
   workgroup = EXAMPLE
790
 
   ...
791
 
   security = user
792
 
</programlisting>
793
 
 
794
 
        </step>
795
 
        <step>
796
 
 
797
 
          <para>
798
 
          In the commented <quote>Domains</quote> section add or uncomment the following:
799
 
          </para>
800
 
 
801
 
<programlisting>
802
 
   domain logons = yes
803
 
   logon path = \\%N\%U\profile
804
 
   logon drive = H:
805
 
   logon home = \\%N\%U
806
 
   logon script = logon.cmd
807
 
   add machine script = sudo /usr/sbin/useradd -N -g machines -c Machine -d /var/lib/samba -s /bin/false %u
808
 
</programlisting>
809
 
 
810
 
          <note>
811
 
            <para>
812
 
            If you wish to not use <emphasis>Roaming Profiles</emphasis> leave the <emphasis>logon home</emphasis>
813
 
            and <emphasis>logon path</emphasis> options commented.
814
 
            </para>
815
 
          </note>
816
 
 
817
 
          <itemizedlist>
818
 
            <listitem>
819
 
              <para>
820
 
              <emphasis>domain logons:</emphasis> provides the netlogon service causing Samba to act as a domain controller.
821
 
              </para>
822
 
            </listitem>
823
 
            <listitem>
824
 
              <para>
825
 
              <emphasis>logon path:</emphasis> places the user's Windows profile into their home directory.  It is also
826
 
              possible to configure a <emphasis>[profiles]</emphasis> share placing all profiles under a single directory.
827
 
              </para>
828
 
            </listitem>
829
 
            <listitem>
830
 
              <para>
831
 
              <emphasis>logon drive:</emphasis> specifies the home directory local path.
832
 
              </para>
833
 
            </listitem>
834
 
            <listitem>
835
 
              <para>
836
 
              <emphasis>logon home:</emphasis> specifies the home directory location.
837
 
              </para>
838
 
            </listitem>
839
 
            <listitem>
840
 
              <para>
841
 
              <emphasis>logon script:</emphasis> determines the script to be run locally once a user has logged in.
842
 
              The script needs to be placed in the <emphasis>[netlogon]</emphasis> share. 
843
 
              </para>
844
 
            </listitem>
845
 
            <listitem>
846
 
              <para>
847
 
              <emphasis>add machine script:</emphasis> a script that will automatically create the 
848
 
              <emphasis>Machine Trust Account</emphasis> needed for a workstation to join the domain.
849
 
              </para>
850
 
              <para>
851
 
              In this example the <emphasis>machines</emphasis> group will need to be created using the 
852
 
              <application>addgroup</application> utility see <xref linkend="adding-deleting-users"/> for details.
853
 
              </para>
854
 
 
855
 
            </listitem>
856
 
          </itemizedlist>
857
 
 
858
 
        </step>
859
 
        <step>
860
 
     
861
 
          <para>
862
 
          Uncomment the <emphasis>[homes]</emphasis> share to allow the <emphasis role="italic">logon home</emphasis>
863
 
          to be mapped:
864
 
          </para>
865
 
 
866
 
<programlisting>
867
 
[homes]
868
 
   comment = Home Directories
869
 
   browseable = no
870
 
   read only = no
871
 
   create mask = 0700
872
 
   directory mask = 0700
873
 
   valid users = %S
874
 
</programlisting>
875
 
 
876
 
        </step>
877
 
        <step>
878
 
 
879
 
          <para>
880
 
          When configured as a domain controller a <emphasis>[netlogon]</emphasis> share needs to be configured.  To 
881
 
          enable the share, uncomment:
882
 
          </para>
883
 
 
884
 
<programlisting>
885
 
[netlogon]
886
 
   comment = Network Logon Service
887
 
   path = /srv/samba/netlogon
888
 
   guest ok = yes
889
 
   read only = yes
890
 
   share modes = no
891
 
</programlisting>
892
 
 
893
 
          <note>
894
 
            <para>
895
 
            The original <emphasis>netlogon</emphasis> share path is <filename>/home/samba/netlogon</filename>, but according 
896
 
            to the Filesystem Hierarchy Standard (FHS), 
897
 
            <ulink url="http://www.pathname.com/fhs/pub/fhs-2.3.html#SRVDATAFORSERVICESPROVIDEDBYSYSTEM">/srv</ulink> is the 
898
 
            correct location for site-specific data provided by the system.
899
 
            </para>
900
 
          </note>
901
 
 
902
 
        </step>
903
 
        <step>
904
 
 
905
 
          <para>
906
 
          Now create the <filename role="directory">netlogon</filename> directory, and an empty (for now) 
907
 
          <filename>logon.cmd</filename> script file:
908
 
          </para> 
909
 
 
910
 
<screen>
911
 
<command>sudo mkdir -p /srv/samba/netlogon</command>
912
 
<command>sudo touch /srv/samba/netlogon/logon.cmd</command>
913
 
</screen>
914
 
 
915
 
          <para>
916
 
          You can enter any normal Windows logon script commands in <filename>logon.cmd</filename> to customize the
917
 
          client's environment.
918
 
          </para>
919
 
 
920
 
        </step>
921
 
        <step>
922
 
 
923
 
          <para>
924
 
          Restart Samba to enable the new domain controller:
925
 
          </para> 
926
 
 
927
 
<screen>
928
 
<command>sudo restart smbd</command>
929
 
<command>sudo restart nmbd</command>
930
 
</screen>
931
 
 
932
 
        </step>
933
 
        <step>
934
 
 
935
 
          <para>
936
 
          Lastly, there are a few additional commands needed to setup the appropriate rights.
937
 
          </para>
938
 
 
939
 
          <para>
940
 
          With <emphasis>root</emphasis> being disabled by default, in order to join a workstation to the domain, a system
941
 
          group needs to be mapped to the Windows <emphasis>Domain Admins</emphasis> group.  
942
 
          Using the <application>net</application> utility, from a terminal enter:
943
 
          </para>
944
 
 
945
 
<screen>
946
 
<command>sudo net groupmap add ntgroup="Domain Admins" unixgroup=sysadmin rid=512 type=d</command>
947
 
</screen>
948
 
 
949
 
          <note>
950
 
            <para>
951
 
            Change <emphasis role="italic">sysadmin</emphasis> to whichever group you prefer.  Also, the user
952
 
            used to join the domain needs to be a member of the <emphasis>sysadmin</emphasis> group, as well 
953
 
            as a member of the system <emphasis>admin</emphasis> group.  The <emphasis>admin</emphasis> group allows 
954
 
            <application>sudo</application> use.  
955
 
            </para>
956
 
            <para>
957
 
            If the user does not have Samba credentials yet, you can add them with
958
 
            the <application>smbpasswd</application> utility, change the <emphasis>sysadmin</emphasis> username appropriately:
959
 
 
960
 
<screen>
961
 
<command>sudo smbpasswd -a sysadmin</command>
962
 
</screen>
963
 
            </para>
964
 
          </note>
965
 
 
966
 
          <para>
967
 
          Also, rights need to be explicitly provided to the <emphasis>Domain Admins</emphasis> group to allow the 
968
 
          <emphasis>add machine script</emphasis> (and other admin functions) to work. This is achieved by executing:
969
 
          </para>
970
 
<screen>
971
 
<command>net rpc rights grant -U sysadmin "EXAMPLE\Domain Admins" SeMachineAccountPrivilege \
972
 
SePrintOperatorPrivilege SeAddUsersPrivilege SeDiskOperatorPrivilege SeRemoteShutdownPrivilege</command>
973
 
</screen>
974
 
 
975
 
        </step>
976
 
        <step>
977
 
 
978
 
          <para>
979
 
          You should now be able to join Windows clients to the Domain in the same manner as joining them to an 
980
 
          NT4 domain running on a Windows server.
981
 
          </para>
982
 
 
983
 
        </step>        
984
 
 
985
 
      </procedure>
986
 
    </sect2>
987
 
    <sect2 id="samba-bdc-smbpasswd" status="review">
988
 
      <title>Backup Domain Controller</title>
989
 
 
990
 
      <para>
991
 
      With a Primary Domain Controller (PDC) on the network it is best to have a Backup Domain Controller (BDC) as well.
992
 
      This will allow clients to authenticate in case the PDC becomes unavailable.
993
 
      </para>
994
 
 
995
 
      <para>
996
 
      When configuring Samba as a BDC you need a way to sync account information with the PDC.  There are multiple ways of 
997
 
      accomplishing this <application>scp</application>, <application>rsync</application>, or by using <application>LDAP</application> as
998
 
      the <emphasis>passdb backend</emphasis>.
999
 
      </para>
1000
 
 
1001
 
      <para>
1002
 
      Using LDAP is the most robust way to sync account information, because both domain controllers can use the same information in real time.
1003
 
      However, setting up a LDAP server may be overly complicated for a small number of user and computer accounts.  
1004
 
      See <xref linkend="samba-ldap"/> for details.
1005
 
      </para>
1006
 
 
1007
 
      <procedure>
1008
 
        <step>
1009
 
   
1010
 
          <para>
1011
 
          First, install <application>samba</application> and <application>libpam-smbpass</application>.  From a terminal enter:
1012
 
          </para>
1013
 
 
1014
 
<screen>
1015
 
<command>sudo apt-get install samba libpam-smbpass</command>
1016
 
</screen>
1017
 
 
1018
 
        </step>
1019
 
        <step>
1020
 
 
1021
 
          <para>
1022
 
          Now, edit <filename>/etc/samba/smb.conf</filename> and uncomment the following in the <emphasis>[global]</emphasis>:
1023
 
          </para>
1024
 
 
1025
 
<programlisting>
1026
 
   workgroup = EXAMPLE
1027
 
   ...
1028
 
   security = user
1029
 
</programlisting>
1030
 
 
1031
 
        </step>
1032
 
        <step>
1033
 
 
1034
 
        <para>
1035
 
        In the commented <emphasis>Domains</emphasis> uncomment or add:
1036
 
        </para>
1037
 
 
1038
 
<programlisting>
1039
 
   domain logons = yes
1040
 
   domain master = no
1041
 
</programlisting>
1042
 
        
1043
 
        </step>
1044
 
        <step>
1045
 
 
1046
 
          <para>
1047
 
          Make sure a user has rights to read the files in <filename>/var/lib/samba</filename>.  For example, to allow users in the 
1048
 
          <emphasis>admin</emphasis> group to <application>scp</application> the files, enter:
1049
 
          </para>
1050
 
 
1051
 
<screen>
1052
 
<command>sudo chgrp -R admin /var/lib/samba</command>
1053
 
</screen>
1054
 
 
1055
 
        </step>
1056
 
        <step>
1057
 
 
1058
 
          <para>
1059
 
          Next, sync the user accounts, using <application>scp</application> to copy the <filename>/var/lib/samba</filename> 
1060
 
          directory from the PDC:
1061
 
          </para>
1062
 
 
1063
 
<screen>
1064
 
<command>sudo scp -r username@pdc:/var/lib/samba /var/lib</command>
1065
 
</screen>
1066
 
 
1067
 
          <note>
1068
 
            <para>
1069
 
            Replace <emphasis>username</emphasis> with a valid username and <emphasis>pdc</emphasis> with the hostname or IP Address of your
1070
 
            actual PDC. 
1071
 
            </para>
1072
 
          </note>
1073
 
 
1074
 
        </step>
1075
 
        <step>
1076
 
          
1077
 
          <para>
1078
 
          Finally, restart <application>samba</application>:
1079
 
          </para>
1080
 
 
1081
 
<screen>
1082
 
<command>sudo restart smbd</command>
1083
 
<command>sudo restart nmbd</command>
1084
 
</screen>
1085
 
 
1086
 
        </step>
1087
 
      </procedure>
1088
 
 
1089
 
      <para>
1090
 
      You can test that your Backup Domain controller is working by stopping the Samba daemon on the PDC, then trying to login to a 
1091
 
      Windows client joined to the domain.
1092
 
      </para>
1093
 
 
1094
 
      <para>
1095
 
      Another thing to keep in mind is if you have configured the <emphasis>logon home</emphasis> option as a directory on the PDC,
1096
 
      and the PDC becomes unavailable, access to the user's <emphasis>Home</emphasis> drive will also be unavailable.  For this reason
1097
 
      it is best to configure the <emphasis>logon home</emphasis> to reside on a separate file server from the PDC and BDC.
1098
 
      </para>
1099
 
 
1100
 
    </sect2>
1101
 
    <sect2 id="samba-dc-resources" status="review">
1102
 
      <title>Resources</title>
1103
 
 
1104
 
      <itemizedlist>
1105
 
        <listitem>
1106
 
          <para>
1107
 
          For in depth Samba configurations see the 
1108
 
          <ulink url="http://samba.org/samba/docs/man/Samba-HOWTO-Collection/">Samba HOWTO Collection</ulink>
1109
 
          </para>
1110
 
        </listitem>
1111
 
        <listitem>
1112
 
          <para>
1113
 
          The guide is also available in 
1114
 
          <ulink url="http://www.amazon.com/exec/obidos/tg/detail/-/0131882228">printed format</ulink>.
1115
 
          </para>
1116
 
        </listitem>
1117
 
        <listitem>
1118
 
          <para>
1119
 
          O'Reilly's <ulink url="http://www.oreilly.com/catalog/9780596007690/">Using Samba</ulink> is also a good
1120
 
          reference.
1121
 
          </para>
1122
 
        </listitem>
1123
 
        <listitem>
1124
 
          <para>
1125
 
          <ulink url="http://samba.org/samba/docs/man/Samba-HOWTO-Collection/samba-pdc.html">Chapter 4</ulink> 
1126
 
          of the Samba HOWTO Collection explains setting up a Primary Domain Controller.
1127
 
          </para>
1128
 
        </listitem>
1129
 
        <listitem>
1130
 
          <para>
1131
 
          <ulink url="http://us3.samba.org/samba/docs/man/Samba-HOWTO-Collection/samba-bdc.html">Chapter 5</ulink> 
1132
 
          of the Samba HOWTO Collection explains setting up a Backup Domain Controller.
1133
 
          </para>
1134
 
        </listitem>
1135
 
        <listitem>
1136
 
          <para>
1137
 
          The <ulink url="https://help.ubuntu.com/community/Samba">Ubuntu Wiki Samba </ulink> page.
1138
 
          </para>
1139
 
        </listitem>
1140
 
      </itemizedlist>
1141
 
   
1142
 
    </sect2>
1143
 
  </sect1>
1144
 
  <sect1 id="samba-ad-integration" status="review">
1145
 
    <title>Samba Active Directory Integration</title>
1146
 
 
1147
 
    <sect2 id="ad-integration-samba-share" status="review">
1148
 
      <title>Accessing a Samba Share</title>
1149
 
 
1150
 
      <para>
1151
 
      Another, use for Samba is to integrate into an existing Windows network.  Once part of an Active Directory domain,
1152
 
      Samba can provide file and print services to AD users.
1153
 
      </para> 
1154
 
 
1155
 
      <para>
1156
 
      The simplest way to join an AD domain is to use <application>Likewise-open</application>.  For detailed instructions
1157
 
      see <xref linkend="likewise-open"/>.
1158
 
      </para>
1159
 
 
1160
 
      <para>
1161
 
      Once part of the domain, enter the following command in the terminal prompt:
1162
 
      </para>
1163
 
 
1164
 
<screen>
1165
 
<command>sudo apt-get install samba smbfs smbclient</command>
1166
 
</screen>
1167
 
 
1168
 
      <para>
1169
 
      Since the <application>likewise-open</application> and <application>samba</application> packages use separate 
1170
 
      <filename>secrets.tdb</filename> files, a symlink will need to be created in <filename role="directory">/var/lib/samba</filename>:
1171
 
      </para>
1172
 
 
1173
 
<screen>
1174
 
<command>sudo mv /var/lib/samba/secrets.tdb /var/lib/samba/secrets.tdb.orig</command>
1175
 
<command>sudo ln -s /etc/samba/secrets.tdb /var/lib/samba</command>
1176
 
</screen>
1177
 
 
1178
 
      <para>
1179
 
      Next, edit <filename>/etc/samba/smb.conf</filename> changing:
1180
 
      </para>
1181
 
 
1182
 
<programlisting>
1183
 
   workgroup = EXAMPLE
1184
 
   ...
1185
 
   security = ads
1186
 
   realm = EXAMPLE.COM
1187
 
   ...
1188
 
   idmap backend = lwopen
1189
 
   idmap uid = 50-9999999999
1190
 
   idmap gid = 50-9999999999
1191
 
</programlisting>
1192
 
 
1193
 
      <para>
1194
 
      Restart <application>samba</application> for the new settings to take effect:
1195
 
      </para>
1196
 
 
1197
 
<screen>
1198
 
<command>sudo restart smbd</command>
1199
 
<command>sudo restart nmbd</command>
1200
 
</screen>
1201
 
 
1202
 
      <para>
1203
 
      You should now be able to access any <application>Samba</application> shares from a Windows client.  However, be sure to give
1204
 
      the appropriate AD users or groups access to the share directory.  See <xref linkend="samba-fileprint-security"/> for 
1205
 
      more details.
1206
 
      </para>
1207
 
 
1208
 
    </sect2>
1209
 
    <sect2 id="ad-integration-windows-share" status="review">
1210
 
      <title>Accessing a Windows Share</title>
1211
 
 
1212
 
      <para>
1213
 
      Now that the Samba server is part of the Active Directory domain you can access any Windows server shares:
1214
 
      </para>
1215
 
 
1216
 
      <itemizedlist>
1217
 
        <listitem>
1218
 
 
1219
 
          <para>
1220
 
          To mount a Windows file share enter the following in a terminal prompt:
1221
 
          </para>
1222
 
<screen>
1223
 
<command>mount.cifs //fs01.example.com/share mount_point</command>
1224
 
</screen>
1225
 
 
1226
 
          <para>
1227
 
          It is also possible to access shares on computers not part of an AD domain, but a username and password 
1228
 
          will need to be provided.
1229
 
          </para>
1230
 
 
1231
 
        </listitem>
1232
 
        <listitem>
1233
 
 
1234
 
          <para>
1235
 
          To mount the share during boot place an entry in <filename>/etc/fstab</filename>, for example:
1236
 
          </para>
1237
 
 
1238
 
<programlisting>
1239
 
//192.168.0.5/share /mnt/windows cifs auto,username=steve,password=secret,rw 0        0
1240
 
</programlisting>
1241
 
 
1242
 
        </listitem>
1243
 
        <listitem>
1244
 
 
1245
 
          <para>
1246
 
          Another way to copy files from a Windows server is to use the <application>smbclient</application> utility.  To 
1247
 
          list the files in a Windows share:
1248
 
          </para>
1249
 
 
1250
 
<screen>
1251
 
<command>smbclient //fs01.example.com/share -k -c "ls"</command>
1252
 
</screen>
1253
 
 
1254
 
        </listitem>
1255
 
        <listitem>
1256
 
 
1257
 
          <para>
1258
 
          To copy a file from the share, enter:
1259
 
          </para>
1260
 
 
1261
 
<screen>
1262
 
<command>smbclient //fs01.example.com/share -k -c "get file.txt"</command>
1263
 
</screen>
1264
 
 
1265
 
          <para>
1266
 
          This will copy the <filename>file.txt</filename> into the current directory.
1267
 
          </para>
1268
 
 
1269
 
        </listitem>
1270
 
        <listitem>
1271
 
 
1272
 
          <para>
1273
 
          And to copy a file to the share:
1274
 
          </para>
1275
 
 
1276
 
<screen>
1277
 
<command>smbclient //fs01.example.com/share -k -c "put /etc/hosts hosts"</command>
1278
 
</screen>
1279
 
 
1280
 
          <para>
1281
 
          This will copy the <filename>/etc/hosts</filename> to <filename>//fs01.example.com/share/hosts</filename>.
1282
 
          </para>
1283
 
 
1284
 
        </listitem>
1285
 
        <listitem>
1286
 
 
1287
 
          <para>
1288
 
          The <emphasis>-c</emphasis> option used above allows you to execute the <application>smbclient</application> command
1289
 
          all at once.  This is useful for scripting and minor file operations.  To enter the <emphasis>smb: \&gt;</emphasis>
1290
 
          prompt, a FTP like prompt where you can execute normal file and directory commands, simply execute:
1291
 
          </para>
1292
 
 
1293
 
<screen>
1294
 
<command>smbclient //fs01.example.com/share -k</command>
1295
 
</screen>
1296
 
 
1297
 
        </listitem>
1298
 
      </itemizedlist>
1299
 
 
1300
 
      <note>
1301
 
        <para>
1302
 
        Replace all instances of <emphasis>fs01.example.com/share</emphasis>, <emphasis>//192.168.0.5/share</emphasis>, 
1303
 
        <emphasis>username=steve,password=secret</emphasis>, and <emphasis>file.txt</emphasis> with your server's IP, hostname, 
1304
 
        share name, file name, and an actual username and password with rights to the share.
1305
 
        </para>
1306
 
      </note>
1307
 
 
1308
 
    </sect2>
1309
 
    <sect2 id="ad-integration-resources" status="review">
1310
 
      <title>Resources</title>
1311
 
 
1312
 
      <para>
1313
 
      For more <application>smbclient</application> options see the man page: <command>man smbclient</command>, also available
1314
 
      <ulink url="http://manpages.ubuntu.com/manpages/&distro-short-codename;/en/man1/smbclient.1.html">online</ulink>.
1315
 
      </para>
1316
 
 
1317
 
      <para>
1318
 
      The <application>mount.cifs</application> 
1319
 
      <ulink url="http://manpages.ubuntu.com/manpages/&distro-short-codename;/en/man8/mount.cifs.8.html">man page</ulink> is also useful for 
1320
 
      more detailed information.
1321
 
      </para>
1322
 
 
1323
 
      <para>
1324
 
      The <ulink url="https://help.ubuntu.com/community/Samba">Ubuntu Wiki Samba </ulink> page.
1325
 
      </para>
1326
 
 
1327
 
    </sect2>
1328
 
  </sect1>  
1329
 
  <sect1 id="likewise-open" status="review">
1330
 
    <title>Likewise Open</title>
1331
 
 
1332
 
    <para>
1333
 
    <application>Likewise Open</application> simplifies the necessary configuration needed to authenticate a Linux machine to an
1334
 
    Active Directory domain.  Based on <application>winbind</application>, the <application>likewise-open</application> package
1335
 
    takes the pain out of integrating Ubuntu authentication into an existing Windows network.
1336
 
    </para>
1337
 
 
1338
 
    <sect2 id="likewise-open-install" status="review">
1339
 
      <title>Installation</title>
1340
 
    
1341
 
      <para>
1342
 
      There are two ways to use Likewise Open, <application>likewise-open</application> the command line utility and 
1343
 
      <application>likewise-open-gui</application>.  This section focuses on the command line utility.
1344
 
      </para>
1345
 
 
1346
 
      <para>
1347
 
      To install the <application>likewise-open</application> package, open a terminal prompt and enter:
1348
 
      </para>
1349
 
 
1350
 
<screen>
1351
 
<command>sudo apt-get install likewise-open</command>
1352
 
</screen>
1353
 
 
1354
 
    </sect2>
1355
 
    <sect2 id="likewise-open-configuration" status="review">
1356
 
      <title>Joining a Domain</title>
1357
 
      
1358
 
      <para>
1359
 
      The main executable file of the <application>likewise-open</application> package is 
1360
 
      <filename>/usr/bin/domainjoin-cli</filename>, which is used to join your computer to the domain. Before you join 
1361
 
      a domain you will need to make sure you have:
1362
 
      </para>
1363
 
    
1364
 
      <itemizedlist>
1365
 
        <listitem>
1366
 
          <para>
1367
 
          Access to an Active Directory user with appropriate rights to join the domain.
1368
 
          </para>
1369
 
        </listitem>
1370
 
        <listitem>
1371
 
          <para>
1372
 
          The <emphasis>Fully Qualified Domain Name</emphasis> (FQDN) of the domain you want to join.  If your AD domain
1373
 
          does not match a valid domain such as <emphasis role="italic">example.com</emphasis>, it is likely that it has
1374
 
          the form of <emphasis>domainname.local</emphasis>.  
1375
 
          </para>
1376
 
        </listitem>
1377
 
        <listitem>
1378
 
          <para>
1379
 
          DNS for the domain setup properly.  In a production AD environment this should be the case.  Proper Microsoft 
1380
 
      DNS is needed so that client workstations can determine the Active Directory domain is available.
1381
 
          </para>
1382
 
          <para>
1383
 
          If you don't have a Windows DNS server on your network, see <xref linkend="likewise-open-ms-dns"/> for details.
1384
 
          </para>
1385
 
          
1386
 
        </listitem>
1387
 
      </itemizedlist>
1388
 
        
1389
 
      <para>
1390
 
      To join a domain, from a terminal prompt enter:
1391
 
      </para>
1392
 
 
1393
 
<screen>
1394
 
<command>sudo domainjoin-cli join example.com Administrator</command>
1395
 
</screen>
1396
 
 
1397
 
      <note>
1398
 
        <para>
1399
 
        Replace <emphasis>example.com</emphasis> with your domain name, and <emphasis>Administrator</emphasis> with the
1400
 
        appropriate user name.
1401
 
        </para>
1402
 
      </note>
1403
 
 
1404
 
      <para>
1405
 
      You will then be prompted for the user's password.  If all goes well a <emphasis>SUCCESS</emphasis> message should be
1406
 
      printed to the console.
1407
 
      </para>
1408
 
 
1409
 
          <note>
1410
 
                  <para>
1411
 
                          After joining the domain, it is necessary to reboot before
1412
 
                          attempting to authenticate against the domain.
1413
 
                  </para>
1414
 
          </note>
1415
 
 
1416
 
      <para>
1417
 
      After successfully joining an Ubuntu machine to an Active Directory domain you can authenticate using any valid AD user.  
1418
 
      To login you will need to enter the user name as 'domain\username'. For example to ssh to a server joined to the domain
1419
 
      enter:
1420
 
      </para>
1421
 
 
1422
 
<screen>
1423
 
<command>ssh 'example\steve'@hostname</command>
1424
 
</screen>
1425
 
 
1426
 
      <note>
1427
 
        <para>
1428
 
        If configuring a Desktop the user name will need to be prefixed with <emphasis role="italic">domain\</emphasis> in the
1429
 
        graphical logon as well.
1430
 
        </para>
1431
 
      </note>
1432
 
 
1433
 
      <para>
1434
 
      To make likewise-open use a default domain, you can add the following statement to <filename>/etc/samba/lwiauthd.conf</filename>:
1435
 
      </para>
1436
 
 
1437
 
<programlisting>
1438
 
winbind use default domain = yes
1439
 
</programlisting>
1440
 
 
1441
 
      <para>
1442
 
      Then restart the <application>likewise-open</application> daemons:
1443
 
      </para>
1444
 
 
1445
 
<screen>
1446
 
<command>sudo /etc/init.d/likewise-open restart</command>
1447
 
</screen>
1448
 
 
1449
 
      <note>
1450
 
        <para>
1451
 
        Once configured for a <emphasis>default domain</emphasis> the <emphasis role="italic">'domain\'</emphasis> is no longer required, 
1452
 
        users can login using only their username.
1453
 
        </para>
1454
 
      </note>
1455
 
 
1456
 
      <para>
1457
 
      The <application>domainjoin-cli</application> utility can also be used to leave the domain.  From a terminal:
1458
 
      </para>
1459
 
 
1460
 
<screen>
1461
 
<command>sudo domainjoin-cli leave</command>
1462
 
</screen>
1463
 
 
1464
 
    </sect2>
1465
 
    <sect2 id="likewise-open-utilities" status="review">
1466
 
      <title>Other Utilities</title>
1467
 
     
1468
 
      <para>
1469
 
      The <application>likewise-open</application> package comes with a few other utilities that may be useful for gathering
1470
 
      information about the Active Directory environment.  These utilities are used to join the machine to the domain, and are
1471
 
      the same as those available in the <application>samba-common</application> and <application>winbind</application> 
1472
 
      packages:
1473
 
      </para>
1474
 
 
1475
 
      <itemizedlist>
1476
 
        <listitem>
1477
 
          <para>
1478
 
          <application>lwinet</application>:  Returns information about the network and the domain.
1479
 
          </para>
1480
 
        </listitem>
1481
 
        <listitem>
1482
 
          <para>
1483
 
          <application>lwimsg</application>:  Allows interaction with the <application>likewise-winbindd</application> daemon.
1484
 
          </para>
1485
 
        </listitem>
1486
 
        <listitem>
1487
 
          <para>
1488
 
          <application>lwiinfo</application>:  Displays information about various parts of the Domain.
1489
 
          </para>
1490
 
        </listitem>
1491
 
      </itemizedlist>
1492
 
        
1493
 
      <para>
1494
 
      Please refer to each utility's man page specific for details.
1495
 
      </para>
1496
 
 
1497
 
      </sect2>
1498
 
      <sect2 id="likewise-open-troubleshooting" status="review">
1499
 
        <title>Troubleshooting</title>
1500
 
 
1501
 
        <itemizedlist>
1502
 
          <listitem>  
1503
 
            <para>
1504
 
            If the client has trouble joining the domain, double check that the Microsoft DNS is listed first in <filename>/etc/resolv.conf</filename>.
1505
 
            For example:
1506
 
            </para>
1507
 
 
1508
 
<programlisting>
1509
 
nameserver 192.168.0.1
1510
 
</programlisting>
1511
 
          </listitem>
1512
 
          <listitem>  
1513
 
            <para>
1514
 
            For more information when joining a domain, use the <emphasis>--loglevel verbose</emphasis> or <emphasis>--advanced</emphasis> option of the 
1515
 
            <application>domainjoin-cli</application> utility:
1516
 
            </para>
1517
 
 
1518
 
<screen>
1519
 
<command>sudo domainjoin-cli --loglevel verbose join example.com Administrator</command>
1520
 
</screen>
1521
 
          </listitem>
1522
 
          <listitem>
1523
 
            <para>
1524
 
            If an Active Directory user has trouble logging in, check the <filename>/var/log/auth.log</filename> for details.
1525
 
            </para>
1526
 
          </listitem>
1527
 
          <listitem>
1528
 
            <para>
1529
 
            When joining an Ubuntu Desktop workstation to a domain, you may need to edit <filename>/etc/nsswitch.conf</filename> if your AD domain 
1530
 
            uses the <emphasis role="italic">.local</emphasis> syntax.  In order to join the domain the <emphasis>"mdns4"</emphasis> entry should be removed from the
1531
 
            <emphasis>hosts</emphasis> option.  For example:
1532
 
            </para>
1533
 
 
1534
 
<programlisting>
1535
 
hosts: files mdns4_minimal [NOTFOUND=return] dns mdns4
1536
 
</programlisting>
1537
 
 
1538
 
            <para>
1539
 
            Change the above to:
1540
 
            </para>
1541
 
 
1542
 
<programlisting>
1543
 
hosts: files dns [NOTFOUND=return]
1544
 
</programlisting>
1545
 
 
1546
 
            <para>
1547
 
            Then restart networking by entering:
1548
 
            </para>
1549
 
 
1550
 
<screen>
1551
 
<command>sudo /etc/init.d/networking restart</command>
1552
 
</screen>
1553
 
        
1554
 
            <para>
1555
 
            You should now be able to join the Active Directory domain.
1556
 
            </para>
1557
 
          </listitem>
1558
 
        </itemizedlist>
1559
 
 
1560
 
      </sect2>
1561
 
      <sect2 id="likewise-open-ms-dns" status="review">
1562
 
        <title>Microsoft DNS</title>
1563
 
      
1564
 
        <para>
1565
 
        The following are instructions for installing DNS on an Active Directory domain controller running Windows Server 2003, 
1566
 
        but the instructions should be similar for other versions:
1567
 
        </para>
1568
 
 
1569
 
<!-- Translators: please check http://www.microsoft.com/language/en/us/search.mspx to see how this string is translated in Windows to your language -->
1570
 
 
1571
 
        <itemizedlist>
1572
 
            <listitem>
1573
 
              <para>
1574
 
              Click 
1575
 
              <menuchoice>
1576
 
                <guimenuitem>Start</guimenuitem><guimenuitem>Administrative Tools</guimenuitem><guimenuitem>Manage Your Server</guimenuitem>
1577
 
              </menuchoice>.
1578
 
              This will open the <application>Server Role Mangement</application> utility.
1579
 
              </para>
1580
 
             <orderedlist>
1581
 
               <listitem><para>Click <guilabel>Add or remove a role</guilabel></para></listitem>
1582
 
               <listitem><para>Click Next</para></listitem>
1583
 
               <listitem><para>Select "DNS Server"</para></listitem>
1584
 
               <listitem><para>Click Next</para></listitem>
1585
 
               <listitem><para>Click Next again to proceed </para></listitem>
1586
 
               <listitem><para>Select "Create a forward lookup zone" if it is not selected.</para></listitem>
1587
 
               <listitem><para>Click Next</para></listitem>
1588
 
               <listitem><para>Make sure "This server maintains the zone" is selected and click Next.</para></listitem>
1589
 
               <listitem><para>Enter your domain name and click Next</para></listitem>
1590
 
               <listitem><para>Click Next to "Allow only secure dynamic updates"</para></listitem>
1591
 
               <listitem>
1592
 
                 <para>
1593
 
                 Enter the IP for DNS servers to forward queries to, or Select "No, it should not forward queries" and click Next.
1594
 
                 </para>
1595
 
               </listitem>
1596
 
               <listitem><para>Click Finish</para></listitem>
1597
 
               <listitem><para>Click Finish</para></listitem>
1598
 
              </orderedlist>
1599
 
              <para>
1600
 
              DNS is now installed and can be further configured using the <application>Microsoft Management Console</application> DNS snap-in.
1601
 
              </para>
1602
 
            </listitem>
1603
 
            <listitem>
1604
 
              <para>
1605
 
              Next, configure the Server to use itself for DNS queries:
1606
 
                <orderedlist>
1607
 
                  <listitem><para>Click Start</para></listitem>
1608
 
                  <listitem><para>Control Panel</para></listitem>
1609
 
                  <listitem><para>Network Connections</para></listitem>
1610
 
                  <listitem><para>Right Click "Local Area Connection"</para></listitem>
1611
 
                  <listitem><para>Click Properties</para></listitem>
1612
 
                  <listitem><para>Double click "Internet Protocol (TCP/IP)"</para></listitem>
1613
 
                  <listitem><para>Enter the Server's IP Address as the "Preferred DNS server"</para></listitem>
1614
 
                  <listitem><para>Click Ok</para></listitem>
1615
 
                  <listitem><para>Click Ok again to save the settings</para></listitem>
1616
 
                </orderedlist>
1617
 
              </para>
1618
 
            </listitem>
1619
 
          </itemizedlist>
1620
 
      </sect2>
1621
 
      <sect2 id="likewise-open-references" status="review">
1622
 
        <title>References</title>
1623
 
       
1624
 
        <para>
1625
 
        Please refer to the <ulink url="http://www.likewisesoftware.com/">Likewise</ulink> home page for further information.
1626
 
        </para> 
1627
 
 
1628
 
        <para>
1629
 
        For more <application>domainjoin-cli</application> options see the man page: <command>man domainjoin-cli</command>.
1630
 
        </para> 
1631
 
 
1632
 
    <para>
1633
 
    Also, see the <ulink url="https://help.ubuntu.com/community/LikewiseOpen">Ubuntu Wiki LikewiseOpen</ulink> page.
1634
 
    </para>
1635
 
 
1636
 
      </sect2>
1637
 
  </sect1>
1638
 
</chapter>