- Active Directory integration
- Contents
- Introduction
- Needed software
- Initial configuration of services
- DNS configuration
- NTP configuration
- Kerberos configuration
- Samba configuration
- Base Samba configuration file
- Joining the domain
- Start the individual Samba services
- Configure NSS
- Testing NSS
- Configuring PAM authentication
- Old Wiki Article
- Terminology
- Active Directory configuration
- GPO considerations
- Linux host configuration
- Installation
- Updating DNS
- Configuring NTP
- Kerberos
- pam_winbind.conf
- Samba
- Join the domain
- Starting and testing services
- Starting Samba
- Testing Winbind
- Testing nsswitch
- Testing Samba commands
- Configuring PAM
Active Directory integration
This article or section needs expansion.
Active Directory (AD) is a directory service that Microsoft developed for Windows domain networks.
This article describes how to integrate an Arch Linux system with an existing Windows domain network using Samba.
Before continuing, you must have an existing Active Directory domain, and have a user with the appropriate rights within the domain to: query users and add computer accounts (Domain Join).
This document is not an intended as a complete guide to Active Directory nor Samba. Refer to the resources section for additional information.
Contents
Introduction
This article explains how to configure an Arch Linux system to participate in an Active Directory domain. This article was written and tested on a fresh installation, and it is assumed that all configuration files are in their unmodified, post-installation state. For the duration of the article, the example Active Directory domain will use the following configuration:
- NetBIOS domain name: INTERNAL
- DNS domain name: internal.domain.tld
- Kerberos realm: INTERNAL.DOMAIN.TLD
- First DC: server1.internal.domain.tld with IP address 192.168.1.1
- Second DC: server2.internal.domain.tld with IP address 192.168.1.2
In most small networks, the DCs (domain controllers) also hold the DNS server role. This may not be true in larger networks. Generally, DCs also hold the NTP role, but not always. Consult your network administrator to verify correct values for DNS and NTP servers.
Needed software
In order to use samba effectively, you will need to install the following packages: samba , smbclient , and ntp . (timedatectl can be used as an alternative to ntp.)
Additionally, while not required, the following packages will be useful for testing and troubleshooting: bind , krb5 , and if a printing is desired (whether you want to share printers, or use printers on another Samba/Windows host), cups .
Initial configuration of services
DNS configuration
Active Directory depends entirely on DNS for name resolution. It is imperative that the /etc/resolv.conf file is configured with both the correct DNS servers and a domain search suffix. Whether configured via DHCP or static configuration, ensure that these values are correct for your domain. For the example domain configuration, the following contents are appropriate (be sure to replace 192.168.1.1, 192.168.1.2, and internal.domain.tld with appropriate values for your network):
If you elected to install the bind package, you can test DNS configuration with the following commands (be sure to replace server1 and internal.domain.tld with appropriate values for your network):
You should get output similar to the following (adjust appropriately for only one DC, or more than two):
NTP configuration
In an Active Directory domain, more specifically for Kerberos ticketing, it is imperative that time is synchronized will all other hosts on the network. A margin of error no more than five minutes is required. For the example domain configuration, an appropriate /etc/ntp.conf file should have the following contents (be sure to replace server1, server2, and internal.domain.tld with appropriate values for your network):
Enable and start the ntpd.service unit.
Kerberos configuration
The Samba documentation recommends a minimal Kerberos configuration, with just enough information in the [libdefaults] section to hand off the work of discovering domain details to DNS. Unfortunately, this does not work well in practice. Continuing with the example domain configuration, modify the /etc/krb.conf file with the following contents (be sure to replace instances of INTERNAL, internal.domain.tld, SERVER1, and INTERNAL.DOMAIN.TLD with appropriate values for your network):
Samba configuration
Base Samba configuration file
A default installation of samba does not ship with an example /etc/samba/smb.conf file. For our example domain configuration, use the following base settings (replace instances of INTERNAL and INTERNAL.DOMAIN.TLD with appropriate values for your network):
If you do not wish to share local printers configured in cups , then add the following to the [Global] section of the /etc/samba/smb.conf file:
The remainder of the configuration depends on whether your domain supports RFC2307 Unix/NFS Attributes. Consult with your domain administrator if unsure.
Adding the idmap configuration for domains with RFC2307 extensions
Be certain that the values below do not overlap with system values, and that all users have at least the uidNubmer attribute, and that those users’ PrimaryGroup has a gid attribute. Append to the following to the the [Global] section of the /etc/samba/smb.conf file (replace INTERNAL with the NetBIOS domain name):
Additionally, if user accounts in AD have a gidNumber attribute, you can use it instead of the RID for the user’s Primary Group by appending the following setting (again in the [Global] section):
Adding the idmap configuration for domains without RFC2307 extensions
If your administrator has not extended the AD schema to include the RFC2307 attributes, use the following idmap configuration in the [Global] section of the /etc/samba/smb.conf file (replace INTERNAL with the NetBIOS domain name):
Joining the domain
To join the AD domain, simply issue the following command (be sure to replace Administrator with a user that has privileges to join the AD domain).
Start the individual Samba services
Enable and start the smb.service , nmb.service , and winbind.service services.
Configure NSS
Modify the /etc/nsswitch.conf file to allow Samba to map names to uid and gid:
Testing NSS
Verify connectivity by listing the AD domain users and groups that system is aware of:
You should get a list of AD users followed by AD groups.
Configuring PAM authentication
Rather than configuring options directly in the Linux-PAM configuration files, set defaults for the pam_winbind module in /etc/security/pam_winbind.conf :
For most services, it will be sufficient to modify only the /etc/pam.d/system-auth file. Any configuration for programs that do not include this file will also need to be modified directly. Create a backup of the /etc/pam.d/system-auth file and use the following configuration:
If you have other services that do not include the /etc/pam.d/system-auth file, modify the configuration to mirror all pam_unix.so entries for pam_winbind.so and change all required to sufficient. A good example is the su configuration. Create a backup of the /etc/pam.d/su file and use the following in its place:
The above pam_winbind configuration will not use the default location of the Kerberos ticket ( KRB5CCNAME ), which is at /tmp/krb5cc_UID . Instead, it stores the automatically refreshed Kerberos ticket to /run/user/UID/krb5cc . Append the following to your krb5.conf to let Kerberos know your new location:
To test your changes, start a new console or ssh session (do not exit your existing session until you have tested thoroughly) and try to login using the AD credentials. The domain name is optional, as this was set in the Winbind configuration as ‘default realm’. Please note that in the case of ssh, you will need to modify the /etc/ssh/sshd_config file to allow kerberos authentication (see below).
Run klist to verify that you have received a kerberos ticket. You should see something similar to:
Finally, you should test login as both the root user and a local unprivileged user before logging out of your existing (working) session.
Old Wiki Article
Active Directory serves as a central location for network administration and security. It is responsible for authenticating and authorizing all users and computers within a Windows domain network, assigning and enforcing security policies for all computers in a network and installing or updating software on network computers. For example, when a user logs into a computer that is part of a Windows domain, it is Active Directory that verifies his or her password and specifies whether they is a system administrator or normal user. Server computers on which Active Directory is running are called domain controllers.
Active Directory uses Lightweight Directory Access Protocol (LDAP) versions 2 and 3, Microsoft’s version of Kerberos and DNS.
Terminology
If you are not familiar with Active Directory, there are a few keywords that are helpful to know.
- Domain : The name used to group computers and accounts.
- SID : Each computer that joins the domain as a member must have a unique SID or System Identifier.
- SMB : Server Message Block.
- NETBIOS: Network naming protocol used as an alternative to DNS. Mostly legacy, but still used in Windows Networking.
- WINS: Windows Information Naming Service. Used for resolving Netbios names to windows hosts.
- Winbind: Protocol for windows authentication.
Active Directory configuration
This section works with the default configuration of Windows Server 2012 R2.
GPO considerations
Digital signing is enabled by default in Windows Server, and must be enabled at both the client and server level. For certain versions of Samba, Linux clients may experience issues connecting to the domain and/or shares. It’s recommended you add the following parameters to your smb.conf file:
If that is not successful, you can disable Digital Sign Communication (Always) in the AD group policies. In your AD Group Policy editor, locate:
Under Local policies > Security policies > Microsoft Network Server > Digital sign communication (Always) activate define this policy and use the disable radio button.
If you use Windows Server 2008 R2, you need to modify that in GPO for Default Domain Controller Policy > Computer Setting > Policies > Windows Setting > Security Setting > Local Policies > Security Option > Microsoft network client: Digitally sign communications (always).
Please note that disabling this GPO affects the security of all members of the domain.
Linux host configuration
The next few steps will begin the process of configuring the Host. You will need root or sudo access to complete these steps.
Installation
Install the following packages:
Updating DNS
Active Directory is heavily dependent upon DNS. You will need to update /etc/resolv.conf to use one or more of the Active Directory domain controllers:
Replacing and with valid IP addresses for the AD servers. If your AD domains do not permit DNS forwarding or recursion, you may need to add additional resolvers.
Configuring NTP
Read System time#Time synchronization to configure an NTP service.
On the NTP servers configuration, use the IP addresses for the AD servers, as they typically run NTP as a service. Alternatively, you can use other known NTP servers provided the Active directory servers sync to the same stratum.
Ensure that the service is configured to sync the time automatically very early on startup.
Kerberos
Let us assume that your AD is named example.com. Let us further assume your AD is ruled by two domain controllers, the primary and secondary one, which are named PDC and BDC, pdc.example.com and bdc.example.com respectively. Their IP adresses will be 192.168.1.2 and 192.168.1.3 in this example. Take care to watch your syntax; upper-case is very important here.
Creating a Kerberos ticket
Now you can query the AD domain controllers and request a kerberos ticket (uppercase is necessary):
You can use any username that has rights as a Domain Administrator.
Validating the Ticket
Run klist to verify you did receive the token. You should see something similar to:
pam_winbind.conf
If you get errors stating that /etc/security/pam_winbind.conf was not found, create the file and add the following:
With this setup, winbind will create user keytabs on the fly (krb5_ccache_type = FILE) at login and maintain them. You can verify this by simply running klist in a shell after logging in as an AD user but without needing to run kinit. You may need to set additional permissions on /etc/krb5.keytab eg 640 instead of 600 to get this to work (see FS#52621 for example)
Samba
Samba is a free software re-implementation of the SMB/CIFS networking protocol. It also includes tools for Linux machines to act as Windows networking servers and clients.
In this section, we will focus on getting Authentication to work first by editing the ‘Global’ section first. Later, we will go back and add shares.
Join the domain
You need an AD Administrator account to do this. Let us assume this is named Administrator. The command is ‘net ads join’
Starting and testing services
Starting Samba
Hopefully, you have not rebooted yet! Fine. If you are in an X-session, quit it, so you can test login into another console, while you are still logged in.
Enable and start the individual Samba daemons smbd.service , nmbd.service , and winbindd.service .
Next we will need to modify the NSSwitch configuration, which tells the Linux host how to retrieve information from various sources and in which order to do so. In this case, we are appending Active Directory as additional sources for Users, Groups, and Hosts.
Testing Winbind
Let us check if winbind is able to query the AD. The following command should return a list of AD users:
- Note we created an Active Directory user called ‘test.user’ on the domain controller
We can do the same for AD groups:
Testing nsswitch
To ensure that our host is able to query the domain for users and groups, we test nsswitch settings by issuing the ‘getent’ command.
The following output shows what a stock ArchLinux install looks like:
Testing Samba commands
Try out some net commands to see if Samba can communicate with AD:
Configuring PAM
Now we will change various rules in PAM to allow Active Directory users to use the system for things like login and sudo access. When changing the rules, note the order of these items and whether they are marked as required or sufficient is critical to things working as expected. You should not deviate from these rules unless you know how to write PAM rules.
Источник