Samba PDF
Samba PDF
Samba PDF
S
amba is an open source implementation of the provisioning will fail (it writes a new one and wont
WHY DO THIS? protocols for user and resource management overwrite an existing one):
Administer Windows in a Windows network. It allows Unix-like $ rm /etc/samba/smb.conf
machines on a network operating systems such as Linux and OS X to share You should also ensure that your server is
without having to files and printers, and to authenticate and manage configured with a static IP address and has itself
abandon your Linux
working environment. users and resources in a Windows network. listed as its primary name server. If you need help
Learn one of the most The venerable version 3 series had long satisfied configuring this, our Network Configuration box
important features in the file sharing needs of many Linux systems, until explains what to do.
Samba 4. Microsoft introduced its Active Directory user and Interactive provisioning prompts for you to enter
resource management infrastructure. But version 4 the required information but offers default values
of Samba resolves this, because it is fully-compatible that are usually acceptable. The first question asks
with it. In this tutorial, well install the Samba Version 4 for a Realm, which is the domain suffix that Active
server and configure it as an Active Directory Domain Directory will apply to all hosts that join the domain.
Controller. Up-to-date distros should have updated The default value is the default search domain for
their Samba version, but you can always download your network, as defined in /etc/resolv.conf and
the latest sources from the samba.org website. Well converted to upper case letters (eg EXAMPLE.COM)
PRO TIP use the Trusty Tahr Ubuntu Server, version 14.04, as and its fine to accept this suggestion.
Implementing Samba its a long term support release that includes Samba You will also be asked to choose a DNS Backend.
requires root privileges.
sudo -i gives you a root 4.1.6 in its repositories. This makes installation Samba requires a DNS server and implements one
prompt. straightforward as root: internally if you accept the default SAMBA_INTERNAL
$ apt-get install samba smbclient option. This should be suitable for most uses but you
We also installed smbclient, the command line can use an external BIND DNS server if you prefer.
Samba client. Well use it to help test our server. The provisioning tool asks two questions that
Ubuntus Samba package automatically starts the require non-default answers. You need to supply:
daemons upon installation. Were about to reconfigure The DNS Forwarder Address: the IP address of
it, so stop them now: another DNS on your network, such as another
$ stop smbd name server defined in /etc/resolv.conf;
$ stop nmbd An Administrator Password of your choosing that is
Sambas main administration tool, samba-tool, is suitably complex it needs to have least eight
A new server hasnt got used to provision (set up) a new domain controller. characters containing three of these four kinds:
much to share, but theres You need to remove the pre-installed default Samba lower-case letters, upper-case letters, digits and
no harm in looking. configuration file before you begin otherwise symbols. Well use Pa$$w0rd in this tutorial; you
should use something different.
Provisioning can be as simple as:
$ samba-tool domain provision --interactive
however, its best to add some optional arguments to
gain some additional benefits:
$ samba-tool domain provision --interactive --use-rfc2307
--use-xattrs=yes
The --use-rfc2307 argument configures Active
Directory so that it can store Unix user attributes, and
this makes it possible to authenticate Linux users
with Samba. The second argument allows Samba
to support access control lists. These are lists of
permissions that augment the basic user, group and
others entitlements. Windows makes extensive use
of them.
To support access control lists, the Linux kernel
and any filesystem that you want to use with Samba
92 www.linuxvoice.com
SAMBA 4 TUTORIAL
www.linuxvoice.com 93
TUTORIAL SAMBA 4
94 www.linuxvoice.com
SAMBA 4 TUTORIAL
samba-tool, and you can use it to add users like this: Roaming profiles link
$ samba-tool user create myuser to the [profiles] share
This creates a user but doesnt enrich it with configured in smb.conf.
The \%U in the path will
supplementary data that can be stored in Active
be replaced with the
Directory, such as their name and phone number, but
username.
you can use the pdbedit command line tool for that:
$ pdbedit --username myuser --modify --fullname My User
You can edit common user attributes with pdbedit
but there are many more attributes in the directory
that you can access. Youll need a basic grasp of how
LDAP stores data and youll need the LDAP Database
Tools to access it. Install the tools and try some
queries:
$ apt-get install ldb-tools
$ ldbsearch -H /var/lib/samba/private/sam.ldb -b CN=myuser,CN
=Users,DC=example,DC=com
$ ldbsearch -H /var/lib/samba/private/sam.ldb -b
CN=Users,DC=example,DC=com samaccountname=myuser $ id myuser
The first argument points at Sambas database uid=3000021(EXAMPLE\myuser) gid=100(users)
your Active Directory. The second argument is the groups=100(users)
Distinguished Name (DN) to search within (a DN is Domain users have high-numbered UIDs that are
what uniquely identifies a record in LDAP and the base assigned by Active Directory. You can modify this (or
DN specifies where to start the search). What follows any other LDAP attribute) using ldbedit but theyre
the arguments is an expression that selects records kept separately from the main directory. You need a
from the database and fields from those records. If users Security Identifier, or SID, to find them. The SID
the expression is omitted then everything beneath the is another way that Active Directory uniquely identifies
base DN is returned. See man ldapsearch for more. a user. The commands you need are:
PRO TIP
Use your preferred method to try adding a user now, $ wbinfo --name-to-sid myuser
If you have Apparmor on
well make use of myuser in the following examples. If S-1-5-21-3373576103-2381685468-725138442-1109 your server, check that
you need to edit your users record then ldbedit gives SID_USER (1) its configuration allows
you direct edit access to the directory. Be careful not $ ldbedit -H /var/lib/samba/private/idmap.ldb cn=S-1-5-21- access to the Samba
socket (it does on
to alter any internal Active Directory data. You can edit 3373576103-2381685468-725138442-1109 Ubuntu 14.04). See
a user like this: The field that you need to change is xidNumber; /etc/apparmor.d/usr.sbin.
$ ldbedit -H /var/lib/samba/private/sam.ldb -b you can set this to the desired uid value. You only ntpd.
CN=Users,DC=example,DC=com samaccountname=myuser really need to do this when moving existing users
from /etc/passwd into the directory.
Linux login You can try logging in as the user you created
We recommended adding a --use-rfc2307 option earlier, for example:
when provisioning the Samba server. RFC2307 is an $ ssh myuser@my_linux_box
internet standard that Active Directory implements so
that it can store Unix attributes like usernames and When in Roam
PRO TIP
passwords in a standard way. The provisioning option File and print sharing works exactly as it does when
From a Windows
instructs Samba to do similarly and this allows us to Samba is used in the classic, non-Active Directory, command line, use
use Samba to authenticate users that log in to our way by writing stanzas in smb.conf. One thing that a ipconfig /all to check
Linux machines. Microsofts Active Directory domain controller adds to this is Roaming Profiles. network settings such
as DNS.
implementation calls this Identity Management for This feature enables your domain users to log in to
UNIX. If you want to authenticate users in this way, Windows clients and download their user profile
their computers need winbind, a daemon that looks directory. Think about your users habits before
up usernames and passwords in Active Directory. You enabling roaming profiles. Because they are
need to install it, along with libraries that link it into the downloaded and uploaded inefficiently, users storing
authentication process: large amounts of data in their profile can put undue
$ apt-get winbind libnss-winbind libpam-winbind pressure on your Samba server.
NSS is the Name Service Switch and you need to Theres much more to Active Directory than weve
configure it to use winbind as a data source by adding covered here, but you should be able to get your first
it after the options already in place. Our modified server up and running and save yourself from one
Ubuntu /etc/nsswitch.conf looks like this: more proprietary server.
passwd: compat winbind
group: compat winbind
John Lane provides technical solutions to business
You can test these using getent passwd and getent
problems. He has yet to find anything that Linux cant solve.
group, and you can look up your user with id:
www.linuxvoice.com 95