Join Ubuntu 20.04 to Active Directory with SSSD and SSH Access
Overview
This guide walks you through joining an Ubuntu 20.04 machine to an Active Directory domain using SSSD, configuring PAM for AD user logins over SSH, and enabling automatic creation of home directories upon first login.
We’ll also cover troubleshooting steps and verification commands.
Environment Used
Component | Value |
---|---|
Ubuntu Client | ubuntu-client.bazboutey.local |
Active Directory FQDN | bazboutey.local |
Realm (Kerberos) | BAZBOUTEY.LOCAL |
AD Admin Account | Administrator |
Step 1: Prerequisites and Package Installation
1.1 Update system and install required packages
Step 2: Test DNS and Kerberos Configuration
Ensure that the client can resolve the AD domain and discover services.
2.1 Test domain name resolution
2.2 Discover LDAP SRV records
2.3 Get a Kerberos ticket
You should see a valid ticket listed by klist
.
Step 3: Configure Samba and SSSD
3.1 Edit /etc/samba/smb.conf
3.2 Create /etc/sssd/sssd.conf
Paste the following configuration:
3.3 Set proper permissions
Step 4: Join the Domain
Run the following command to join the machine to the domain:
Verify with:
You should see:
Step 5: Start and Restart Services
Check that SSSD is running:
Step 6: Enable Home Directory Creation
Ubuntu must be configured to create user home directories upon login.
6.1 Install the PAM module (already installed via libpam-modules):
✔️ Enable:
-
[x] Create home directory on login
-
[x] SSS Authentication
Step 7: Verify AD User Visibility
7.1 List domain users:
7.2 Query specific user:
7.3 Check allowed groups:
Step 8: Test SSH Login
8.1 Start SSH server (if not already running)
8.2 Test login using AD user:
🔐 On first login, the system will:
-
Prompt for AD password
-
Automatically create
/home/johnd
-
Open a shell if the user is allowed by SSSD and PAM
Optional: Restrict or Extend SSH Access
In /etc/sssd/sssd.conf
, you can control who is allowed:
To allow everyone (not secure for production):
To allow only members of a specific AD group:
Optional: Grant Sudo Access to AD Users
Edit the sudoers file with:
Add:
Or to allow a specific user:
Troubleshooting
Symptom | Fix |
---|---|
id: no such user | Restart SSSD, check /etc/nsswitch.conf includes sss |
pam_sss(sshd:account): Access denied | Ensure user/group is allowed in sssd.conf |
Home dir not created | Enable pam_mkhomedir with pam-auth-update |
SSH connection closes after login | Check shell path, use /bin/bash as default_shell |
Cannot resolve domain | Fix DNS or add proper search line in /etc/resolv.conf |
✅ Final Result
You now have:
-
✅ Ubuntu joined to Active Directory
-
✅ SSH login for AD users
-
✅ Automatic home directory creation
-
✅ PAM + SSSD + Kerberos integrated securely
Comments
Post a Comment