Table Of ContentPractical
LPIC-3 300
Prepare for the Highest Level
Professional Linux Certif ication
—
Antonio Vazquez
Practical LPIC-3 300
Prepare for the Highest Level
Professional Linux Certification
Antonio Vazquez
Practical LPIC-3 300
Antonio Vazquez
Mostoles, Spain
ISBN-13 (pbk): 978-1-4842-4472-2 ISBN-13 (electronic): 978-1-4842-4473-9
https://doi.org/10.1007/978-1-4842-4473-9
Copyright © 2019 by Antonio Vazquez
This work is subject to copyright. All rights are reserved by the Publisher, whether the whole or part of the
material is concerned, specifically the rights of translation, reprinting, reuse of illustrations, recitation,
broadcasting, reproduction on microfilms or in any other physical way, and transmission or information
storage and retrieval, electronic adaptation, computer software, or by similar or dissimilar methodology now
known or hereafter developed.
Trademarked names, logos, and images may appear in this book. Rather than use a trademark symbol with
every occurrence of a trademarked name, logo, or image we use the names, logos, and images only in an
editorial fashion and to the benefit of the trademark owner, with no intention of infringement of the
trademark.
The use in this publication of trade names, trademarks, service marks, and similar terms, even if they are not
identified as such, is not to be taken as an expression of opinion as to whether or not they are subject to
proprietary rights.
While the advice and information in this book are believed to be true and accurate at the date of publication,
neither the authors nor the editors nor the publisher can accept any legal responsibility for any errors or
omissions that may be made. The publisher makes no warranty, express or implied, with respect to the
material contained herein.
Managing Director, Apress LLC: Welmoed Spahr
Acquisitions Editor: Louise Corrigan
Development Editor: James Markham
Coordinating Editor: Nancy Chen
Cover designed by eStudioCalamar
Distributed to the book trade worldwide by Springer Science+Business Media New York, 233 Spring Street,
6th Floor, New York, NY 10013. Phone 1-800-SPRINGER, fax (201) 348-4505, e-mail orders-ny@springer-
sbm.com, or visit www.springeronline.com. Apress Media, LLC is a California LLC and the sole member
(owner) is Springer Science + Business Media Finance Inc (SSBM Finance Inc). SSBM Finance Inc is a
Delaware corporation.
For information on translations, please e-mail [email protected], or visit http://www.apress.com/
rights-permissions.
Apress titles may be purchased in bulk for academic, corporate, or promotional use. eBook versions and
licenses are also available for most titles. For more information, reference our Print and eBook Bulk Sales
web page at http://www.apress.com/bulk-sales.
Any source code or other supplementary material referenced by the author in this book is available to
readers on GitHub via the book’s product page, located at www.apress.com/9781484244722. For more
detailed information, please visit http://www.apress.com/source-code.
Printed on acid-free paper
This book is dedicated to my family, especially to
my daughter and my wife.
Table of Contents
About the Author ���������������������������������������������������������������������������������������������������xvii
About the Technical Reviewer ��������������������������������������������������������������������������������xix
Acknowledgments ��������������������������������������������������������������������������������������������������xxi
Introduction ����������������������������������������������������������������������������������������������������������xxiii
Part I: OpenLDAP ��������������������������������������������������������������������������������������������������1
Chapter 1: Starting with OpenLDAP ��������������������������������������������������������������������������3
The LDAP Protocol �������������������������������������������������������������������������������������������������������������������������3
The OpenLDAP Project ������������������������������������������������������������������������������������������������������������������4
Installing an OpenLDAP Server �����������������������������������������������������������������������������������������������������5
Customizing the Installation ����������������������������������������������������������������������������������������������������������6
Modifying Objects ��������������������������������������������������������������������������������������������������������������������6
Adding Objects ����������������������������������������������������������������������������������������������������������������������15
Logging Access ���������������������������������������������������������������������������������������������������������������������������24
Logging to rsyslog �����������������������������������������������������������������������������������������������������������������������27
Berkeley Database ����������������������������������������������������������������������������������������������������������������������28
Tools ��������������������������������������������������������������������������������������������������������������������������������������������29
Server Tools ���������������������������������������������������������������������������������������������������������������������������30
Client Tools ����������������������������������������������������������������������������������������������������������������������������31
Summary�������������������������������������������������������������������������������������������������������������������������������������32
Chapter 2: Securing the Directory ��������������������������������������������������������������������������33
Securing LDAP Connections with TLS �����������������������������������������������������������������������������������������33
Preparing the Environment ����������������������������������������������������������������������������������������������������34
Creating a CA and a Server Certificate ����������������������������������������������������������������������������������35
Securing the LDAP Protocol ���������������������������������������������������������������������������������������������������39
v
Table of ConTenTs
Firewall Considerations ���������������������������������������������������������������������������������������������������������������45
Access Control ����������������������������������������������������������������������������������������������������������������������������51
Authentication Methods ��������������������������������������������������������������������������������������������������������������56
Simple Bind Authentication ���������������������������������������������������������������������������������������������������56
SASL ��������������������������������������������������������������������������������������������������������������������������������������61
SASL Proxy Authorization ������������������������������������������������������������������������������������������������������������75
Client Certificate �������������������������������������������������������������������������������������������������������������������������79
Security Strength Factor �������������������������������������������������������������������������������������������������������������86
Debugging and Troubleshooting��������������������������������������������������������������������������������������������������86
Summary�������������������������������������������������������������������������������������������������������������������������������������91
Chapter 3: LDAP Integration with PAM and NSS �����������������������������������������������������93
PAM ���������������������������������������������������������������������������������������������������������������������������������������������93
Authenticating Users with LDAP �������������������������������������������������������������������������������������������������94
Troubleshooting LDAP Authentication ���������������������������������������������������������������������������������������106
Configure NSS to Retrieve Information from LDAP �������������������������������������������������������������������110
Configure PAM Modules in Various UNIX Environments ������������������������������������������������������������112
Authenticating from a FreeBSD Box ������������������������������������������������������������������������������������113
Authenticating from a Solaris Box ���������������������������������������������������������������������������������������119
Summary�����������������������������������������������������������������������������������������������������������������������������������122
Chapter 4: Integrating LDAP with Active Directory and Kerberos ������������������������123
Kerberos ������������������������������������������������������������������������������������������������������������������������������������123
Installing Kerberos on CentOS ���������������������������������������������������������������������������������������������125
Configuring the EXAMPLE�COM Realm ��������������������������������������������������������������������������������127
Kerberos Authentication ������������������������������������������������������������������������������������������������������130
Configuring a Customized Realm ����������������������������������������������������������������������������������������134
Troubleshooting Kerberos Authentication ����������������������������������������������������������������������������143
Cross-Platform Authentication ��������������������������������������������������������������������������������������������������143
Authenticating from Windows ���������������������������������������������������������������������������������������������144
Single Sign-on ��������������������������������������������������������������������������������������������������������������������������150
vi
Table of ConTenTs
Integrating OpenLDAP and Active Directory ������������������������������������������������������������������������������150
Active Directory �������������������������������������������������������������������������������������������������������������������151
Delegating Authentication to Active Directory ���������������������������������������������������������������������151
Summary�����������������������������������������������������������������������������������������������������������������������������������155
Chapter 5: OpenLDAP Replication �������������������������������������������������������������������������157
Replication Concepts ����������������������������������������������������������������������������������������������������������������157
Preparation �������������������������������������������������������������������������������������������������������������������������������159
Setting Up the Replication ��������������������������������������������������������������������������������������������������������164
Replication Topologies ��������������������������������������������������������������������������������������������������������������172
Distributed Directory Services ��������������������������������������������������������������������������������������������������174
Troubleshooting ������������������������������������������������������������������������������������������������������������������������179
Summary�����������������������������������������������������������������������������������������������������������������������������������180
Chapter 6: OpenLDAP Server Performance Tuning �����������������������������������������������181
Measure OpenLDAP Performance ���������������������������������������������������������������������������������������������181
Indexes ��������������������������������������������������������������������������������������������������������������������������������������185
DB_CONFIG �������������������������������������������������������������������������������������������������������������������������������189
Summary�����������������������������������������������������������������������������������������������������������������������������������191
Part II: Samba ������������������������������������������������������������������������������������193
Chapter 7: Starting with Samba ���������������������������������������������������������������������������195
Installing Samba �����������������������������������������������������������������������������������������������������������������������195
Creating a Share �����������������������������������������������������������������������������������������������������������������������195
Accessing the Share �����������������������������������������������������������������������������������������������������������������198
Summary�����������������������������������������������������������������������������������������������������������������������������������201
Chapter 8: Samba Concepts and Architecture, Configuring Samba,
and Internationalization ���������������������������������������������������������������������������������������203
Samba Services and Components ��������������������������������������������������������������������������������������������204
Ports Used ���������������������������������������������������������������������������������������������������������������������������������205
Samba 3 and Samba 4 ��������������������������������������������������������������������������������������������������������������206
vii
Table of ConTenTs
Server Configuration �����������������������������������������������������������������������������������������������������������������206
Registry-Based Configuration ���������������������������������������������������������������������������������������������207
Server Configuration File Structure �������������������������������������������������������������������������������������211
Samba Variables and Configuration Parameters �����������������������������������������������������������������������212
Securing the Connections ���������������������������������������������������������������������������������������������������232
Troubleshooting and Debugging Configuration Problems ���������������������������������������������������������237
Character Codes and Code Pages ���������������������������������������������������������������������������������������������238
Summary�����������������������������������������������������������������������������������������������������������������������������������242
Chapter 9: Regular Samba Maintenance and Troubleshooting �����������������������������243
Monitoring Samba Services ������������������������������������������������������������������������������������������������������243
Smbcontrol ��������������������������������������������������������������������������������������������������������������������������244
smbstatus ����������������������������������������������������������������������������������������������������������������������������245
Backing Up Samba Configuration and State Data ���������������������������������������������������������������������245
Restoring Samba Configuration ������������������������������������������������������������������������������������������������247
Configure Samba Logging ���������������������������������������������������������������������������������������������������������249
Back Up TDB Files ���������������������������������������������������������������������������������������������������������������������250
Identify TDB File Corruption ������������������������������������������������������������������������������������������������������250
Restore TDB Files ����������������������������������������������������������������������������������������������������������������������251
Edit and List TDB File Content ���������������������������������������������������������������������������������������������������251
Summary�����������������������������������������������������������������������������������������������������������������������������������255
Chapter 10: File Services in Samba ����������������������������������������������������������������������257
Create and Configure File Sharing ��������������������������������������������������������������������������������������������257
Quotas ���������������������������������������������������������������������������������������������������������������������������������262
File Services Migration �������������������������������������������������������������������������������������������������������������263
Migrate from a Linux Samba Server to Another Linux Samba Server ���������������������������������263
Migrating from Windows to Samba �������������������������������������������������������������������������������������275
Limit Access to IPC$ ������������������������������������������������������������������������������������������������������������������287
Scripts for User and Group Handling of File Shares ������������������������������������������������������������������287
Samba Share Access Configuration Parameters ����������������������������������������������������������������������288
Summary�����������������������������������������������������������������������������������������������������������������������������������291
viii
Table of ConTenTs
Chapter 11: Linux File System and Share and Service Permissions ��������������������293
File and Directory Permission Control���������������������������������������������������������������������������������������293
Linux File System Permissions and Samba ������������������������������������������������������������������������������296
Creating a New Directory in Samba ������������������������������������������������������������������������������������300
Samba VFS ��������������������������������������������������������������������������������������������������������������������������������302
Auditing Samba Operations �������������������������������������������������������������������������������������������������302
Using Samba VFS to Store Windows ACLs ���������������������������������������������������������������������������304
Summary�����������������������������������������������������������������������������������������������������������������������������������315
Chapter 12: Print Services ������������������������������������������������������������������������������������317
Printing in Linux ������������������������������������������������������������������������������������������������������������������������317
Printer Sharing ��������������������������������������������������������������������������������������������������������������������������327
Connecting to a Shared Printer from a Windows Client ������������������������������������������������������329
Connecting to a Shared Printer from a Mac Client ��������������������������������������������������������������333
Connecting to a Shared Printer from a Linux Client ������������������������������������������������������������336
Integrating Samba and CUPS ����������������������������������������������������������������������������������������������������340
smb�conf Printing-Related Options �������������������������������������������������������������������������������������������342
CUPS-Related Options ���������������������������������������������������������������������������������������������������������342
Spoolss ��������������������������������������������������������������������������������������������������������������������������������343
Customizing Printing Options ����������������������������������������������������������������������������������������������343
Windows Printer Drivers �����������������������������������������������������������������������������������������������������������345
Configure [print$] ����������������������������������������������������������������������������������������������������������������345
Printer Sharing Security ������������������������������������������������������������������������������������������������������������346
Point and Print ��������������������������������������������������������������������������������������������������������������������������347
Some Useful Command-Line Utilities ���������������������������������������������������������������������������������������358
Smbspool �����������������������������������������������������������������������������������������������������������������������������359
Rpcclient ������������������������������������������������������������������������������������������������������������������������������359
Summary�����������������������������������������������������������������������������������������������������������������������������������363
ix
Table of ConTenTs
Chapter 13: Managing User Accounts and Groups �����������������������������������������������365
Managing User and Group Accounts �����������������������������������������������������������������������������������������365
Smbpasswd �������������������������������������������������������������������������������������������������������������������������366
Pdbedit ��������������������������������������������������������������������������������������������������������������������������������367
samba-tool ��������������������������������������������������������������������������������������������������������������������������370
Understand User and Group Mapping ���������������������������������������������������������������������������������������373
Forcing Ownership of File and Directory Objects ����������������������������������������������������������������������376
Summary�����������������������������������������������������������������������������������������������������������������������������������379
Chapter 14: Authentication, Authorization, and Winbind �������������������������������������381
Setting Up a Local Password Database ������������������������������������������������������������������������������������382
Performing Password Synchronization �������������������������������������������������������������������������������������382
Knowledge of Different passdb Back Ends and Converting between Different Back Ends �������383
Winbind �������������������������������������������������������������������������������������������������������������������������������������384
Configuring NSS and PAM ���������������������������������������������������������������������������������������������������������391
Summary�����������������������������������������������������������������������������������������������������������������������������������394
Chapter 15: Samba as a PDC and BDC ������������������������������������������������������������������395
Windows Domains ��������������������������������������������������������������������������������������������������������������������395
Trust Relationships ��������������������������������������������������������������������������������������������������������������396
Creating a Samba PDC ��������������������������������������������������������������������������������������������������������������396
Add Computers to an Existing Domain ��������������������������������������������������������������������������������������401
Configuring Logon Scripts ���������������������������������������������������������������������������������������������������������409
Configuring Roaming Profiles ���������������������������������������������������������������������������������������������������411
Implementing System Policies ��������������������������������������������������������������������������������������������������413
Creating a Samba BDC ��������������������������������������������������������������������������������������������������������������417
Summary�����������������������������������������������������������������������������������������������������������������������������������421
Chapter 16: Configuring Samba as a Domain Member Server in an
Existing NT Domain �����������������������������������������������������������������������������������������������423
Joining a Samba Server to an NT4 Domain ������������������������������������������������������������������������������423
Summary�����������������������������������������������������������������������������������������������������������������������������������429
x