Programster's Blog

Tutorials focusing on Linux, programming, and open-source

Ubuntu 18.04 - Deploy Samba Active Directory

This tutorial will explain how to deploy a Samba server to act as an Active Directory (AD) for your Windows network. This is a free alternative to deploying Microsoft Active Directory, and once deployed, can be managed by the same remote tools on Windows workstations.

Related Tutorials

Steps

Install packages

sudo apt update && \
  sudo apt-get install -y krb5-config samba winbind smbclient

Samba's winbindd service provides an interface for the Name Service Switch (NSS) and enables domain users to authenticate to AD when logging into the local system. Using winbindd provides the benefit that you can enhance the configuration to share directories and printers without installing additional software.

Backup the default samba configuration so that we can restore it if things go horribly wrong.

sudo mv /etc/samba/smb.conf /etc/samba/smb.conf.bak

Use the following command to start an interactive prompt for generating a new smb.conf file.

sudo samba-tool domain provision

(I used defaults for everything)

Copy the Kerberos configuration file to the etc directory (I couldn't find this file until I also installed krb5-config)

cp /var/lib/samba/private/krb5.conf /etc/.

Stop and disable some the following services. These will be run by our active directory service later.

sudo systemctl disable --now smbd nmbd winbind systemd-resolved

Unmask the samba active directory service, enable it, and start it.

sudo systemctl unmask samba-ad-dc.service
sudo systemctl enable --now samba-ad-dc.service

Check that everything is running by running:

samba-tool domain level show

Configure server to use our own domain server

sudo rm /etc/resolv.conf
sudo vim /etc/resolv.conf

Put in the IP address of your DNS server(s). E.g.

nameserver 192.168.1.1
nameserver 192.168.1.2

Create user

samba-tool user create myUserName

Enter a password when prompted.

Then you can go back to windows workstation and log in with myUserName and the user you just set.

References

Last updated: 17th June 2020
First published: 16th June 2020