I few days ago I was helping a client to move some systems to run under Linux. They are quite used to Windows environments and they would like to have an environment where they could have a workflow similar to the one they have using Windows servers.
Environment
- Windows 2016 Domain Controller
- Windows 10 Workstations
- Ubuntu 20.04 LTS (Focal Fossa) Application Server
- Sudoers must be granted via Active Directory group
Requirements
- Log to Linux servers using Active Directory account
- Ability to copy files from Windows workstations to Linux servers using Windows Explorer
- Ability to use ACLs on Linux in similar way to how they are done in Windows
Solution
Usage of SSSD - System Security Services Daemon https://sssd.io/
Usage of Samba https://samba.org/
SSSD Configuration
Hostname & DNS
Set a proper hostname for your server with correct domain component.
1 | sudo hostnamectl set-hostname myubuntu.example.com |
Disable systemd-resolve
Ubuntu 20.04 comes with systemd-resolve which you need to disable for the server to access your network DNS directly.
1 | sudo systemctl disable systemd-resolved |
Install required packages
A number of packages are required for joining an Ubuntu 20.04 system to Active Directory (AD) domain.
1 | sudo apt update |
Discover Active Directory domain
The realm discover command returns complete domain configuration and a list of packages that must be installed for the system to be enrolled in the domain.
1 | sudo realm discover example.com |
1 | example.com |
Ensure that all listed packages are also installed.
Join Active Directory (AD) domain
An AD administrative user account is required for integrating your Linux machine with Windows Active Directory domain. Check and confirm AD admin account and the password.
The realm join command will set up the local machine for use with a specified domain by configuring both the local system services and the entries in the identity domain. The command has a number of options which can be checked with:
1 | sudo realm join -U Administrator example.com |
Test your new configuration.
1 | realm list |
Edit /usr/share/pam-configs/mkhomedir
and set Default: yes
to get it enabled.
1 | Name: Create home directory on login |
Activate your configuration.
1 | sudo pam-auth-update |
Ensure “activate mkhomedir” is selected, it should have [*]
Tune your setup
In my scenario I’ve decided to tune some things because I’m dealing with just one domain.
full_name_format = %1$s
to show just username omitting domain nameuse_fully_qualified_names = True
removed to omit domain namefallback_homedir = /home/%u
to create homedirs with just usernamedefault_domain_suffix = example.com
to have a default domain since we are omitting it
Final version of /etc/sssd/sssd.conf
:
1 | [sssd] |
Whenever there is a change in sssd.conf
, restart is required.
1 | sudo systemctl restart sssd |
Test it
Status should be running.
1 | systemctl status sssd |
If the integration is working, it should be possible to get an AD user info.
1 | id jrgcombr |
Configure sudoers
Adjust your visudo
to linux_sudoers
1 | # |
Samba Configuration
Install packages
1 | sudo apt install samba |
Adjust your smb.conf
1 | [global] |
Fix guests mapping on Ububtu
Ubuntu default installation has an issue with S-1-5-32-546
mapping.
1 | sudo net groupmap add sid=S-1-5-32-546 unixgroup=nogroup type=builtin |
Well-known security identifiers in Windows operating systems
Install acl
Ubuntu does not come with acl packages installed but the filesystem does come with acl enabled by default.
1 | sudo apt install acl |
Configure share permissions
Adjust permission to only example_group
members can work on shared files from samba share and from Linux as well.
1 | chmod 2770 /var/example_share |
Check it
1 | getfacl /var/example_share |
Enable samba
1 | sudo systemctl enable smbd |
Conclusion
Setup is now done, by now you should have one samba active directory integrated, clients authenticating via Kerberos and one flat uid/gid structre.