How to allow Linux PAM Authentication for non-Local users

Abstract: Configure Linux PAM to authenticate non-local users against LDAP or Active Directory by installing required packages and editing the common-auth file.

Created: 2026-09-28 by

Linux PAM authentication for non-local users is configured by enabling the pam_ldap.so or pam_sss.so modules in the /etc/pam.d/common-auth file. This allows remote systems to validate credentials against an LDAP directory or Active Directory without storing passwords locally on the Ubuntu server.

Understanding PAM and Non-Local Authentication

The Pluggable Authentication Modules (PAM) framework in Linux provides a flexible way to handle user authentication. By default, most Ubuntu servers rely on local password files stored in /etc/shadow. However, in enterprise environments, it is common to centralize identity management using Lightweight Directory Access Protocol (LDAP) or System Security Services Daemon (SSSD).

When you need to allow non-local users to authenticate, you are essentially telling the system to check with an external source before granting access. This is critical for scenarios where you have hundreds of users managed centrally, and you do not want to create individual local accounts for each one. The configuration involves modifying specific PAM stack files that dictate how authentication requests are processed.

Choosing Between LDAP and SSSD

Historically, direct LDAP integration via pam_ldap was the standard approach. However, modern Ubuntu distributions often prefer SSSD due to its robust caching capabilities and better handling of network interruptions. If your environment uses Active Directory, SSSD is generally the recommended path. For pure LDAP directories, both methods work, but pam_sss is increasingly becoming the default choice in newer releases because it integrates seamlessly with systemd and provides offline login support if configured correctly.

Before proceeding, ensure your network interfaces are properly configured to reach the authentication server. You can verify connectivity and interface status by reviewing guides on Ubuntu Server Network Interfaces. Without stable network access, PAM authentication will fail or hang indefinitely, causing login timeouts.

Installing Required Packages

To begin, you must install the necessary packages that provide the PAM modules. For LDAP-based authentication, the package is typically libpam-ldapd which includes the nss-ldapd components for name service switching. If you are using SSSD, you will need sssd and libnss-sss.

sudo apt update
sudo apt install libpam-ldapd nss-ldapd
# OR for SSSD:
sudo apt install sssd libnss-sss libpam-sss

During installation, you may be prompted to configure basic settings such as the URI of your LDAP server and the base DN. Follow the prompts carefully to ensure the initial configuration is correct. Incorrect URIs here will prevent any subsequent PAM changes from working.

Configuring PAM Stacks

The core of this setup lies in editing the PAM configuration files located in /etc/pam.d/. There are two main files to consider: common-auth and common-session. The common-auth file controls the actual verification of passwords, while common-session manages resource allocation upon successful login.

Edit the common-auth file using a text editor like nano or vim:

sudo nano /etc/pam.d/common-auth

You need to add a line that instructs PAM to use the LDAP or SSSD module. For LDAP, the line typically looks like this:

auth sufficient pam_ldap.so try_first_pass

For SSSD, it would be:

auth sufficient pam_sss.so try_first_pass

The keyword sufficient is important. It means that if this module succeeds, no further authentication checks are needed. If it fails, the system falls back to other methods, such as local password verification. Place this line near the top of the file, but below the standard pam_unix module if you want to prioritize local users, or above it if you want to prioritize remote users. A common practice is to place it after pam_unix so that local root users can still log in even if the LDAP server is down, preventing lockouts.

Similarly, edit /etc/pam.d/common-session to include session management for these users:

session required pam_mkhomedir.so umask=0022 skel=/etc/skel

This optional step ensures that home directories are created automatically when a non-local user logs in for the first time. Without this, users might not have a writable home directory, leading to permission errors.

Verifying Configuration and Testing

After saving the changes, test the configuration immediately. Do not close your current terminal session until you have verified that a new SSH connection works. Opening a second terminal window is highly recommended as a safety net.

Try logging in with a non-local user account:

ssh username@your-server-ip

If the login fails, check the system logs for detailed error messages. The primary log file for PAM events is /var/log/auth.log. Look for entries related to pam_ldap or pam_sss to identify whether the issue is a network timeout, a credential mismatch, or a misconfiguration in the PAM stack.

Note that restarting the SSH daemon (sshd) is generally unnecessary for PAM configuration changes. PAM is loaded dynamically by services at runtime. Restarting services can sometimes cause brief disruptions and is not required for the changes in /etc/pam.d/ to take effect. Instead, simply testing a new connection is sufficient to apply the new rules.

Troubleshooting Common Issues

If you encounter issues, ensure that the LDAP server is reachable and that the firewall allows traffic on port 389 (LDAP) or 636 (LDAPS). Also, verify that the nsswitch.conf file is configured to use LDAP or SSSD for group and password lookups. If you are experiencing dependency errors during installation, refer to resources on installing missing libraries on Ubuntu, as outdated SSL libraries can sometimes interfere with secure LDAP connections.

Frequently Asked Questions

Can I use both local and LDAP authentication?

Yes, by configuring the PAM stack with multiple modules, you can allow both local and remote users. Using the sufficient flag for the LDAP module ensures that if LDAP authentication succeeds, the process stops, but if it fails, it falls back to local authentication.

Why are my home directories not created automatically?

PAM does not create home directories by default. You must explicitly add the pam_mkhomedir.so module to the common-session file. Ensure the module is present and that the target filesystem has sufficient permissions for the creation process.

Does changing PAM configurations require a reboot?

No, a reboot is not required. PAM modules are loaded into memory by the services that use them, such as SSH or Login. Changes take effect immediately for new sessions. Always test with a new SSH connection rather than relying on your existing session.

What is the difference between pam_ldap and pam_sss?

pam_ldap connects directly to an LDAP server for every authentication request. pam_sss communicates with the SSSD daemon, which caches credentials and user information. SSSD is preferred in modern setups because it handles network failures more gracefully and supports offline logins.

How do I debug PAM authentication failures?

Check the /var/log/auth.log file for detailed error messages. Enable verbose logging in your PAM configuration if necessary, but usually, the standard logs provide enough information to identify network issues, syntax errors, or credential mismatches.

Latest News

How to Display Output of xterm Command in Terminal Screen using Cron

Resolve the inability to display xterm output in a terminal screen from cron by redirecting logs or using wall instead of insecure X11 workarounds.

Read More
Expose Local Server on VPS Preserving Real Client IPs (OS Level)

Resolve VPS logging showing only gateway IPs by configuring reverse proxies to forward real client addresses via X-Forwarded-For headers.

Read More
How to Clear Recent Files History in Linux without Deleting Actual Files?

Clear recent files history in Linux by deleting ~/.local/share/recently-used.xbel without removing the actual files.

Read More
Best HDD Copy Strategy: Manually Syncing and Rewriting Scratch

Resolve data drift between two 4TB hard drives by using rsync with the --delete flag to manually sync and rewrite scratch data for an exact mirror.

Read More
Understanding Bash Prompt Abbreviations: An Overview

Resolve repetitive typing errors by creating and persisting Bash aliases in the .bashrc file for improved command-line efficiency.

Read More
Free Tools and Methods to Log Real-Time Performance Details in Task Manager

Log real-time CPU and memory metrics to CSV files using Windows Performance Monitor Data Collector Sets to troubleshoot system slowness.

Read More
Contact Qatar Airways Customer Service: Phone Number, Help Center, and More

Resolve urgent Qatar Airways reservation issues like flight changes and baggage claims using the US phone number +1801-855-5905 or online self-service tools.

Read More
Windows 11: Alt Codes Displaying Wrong Characters - Solutions

Resolve Windows 11 Alt codes showing wrong characters by verifying the US keyboard layout and enabling Num Lock.

Read More
Run Programs with Elevated Privileges: A Comprehensive Guide

Eliminates the need to type sudo for frequent administrative tasks by configuring .bashrc aliases or functions.

Read More
Dynamically Changing Dates in Excel Formulas Using Cells

Eliminate manual date updates in Excel by using cell references to create dynamic formulas that automatically adjust calculations when input dates change.

Read More
Granting Edit Access to a Specific Excel Sheet in an Office 365 User Email ID-Based Login

Excel Online lacks native sheet-level permissions, so users must split workbooks or use worksheet protection to isolate edit access for specific tabs.

Read More
Creating Network Load on Local Wi-Fi from One PC

Generate sustained Wi-Fi bandwidth load from a single PC using a VM SFTP server to test router stability and throughput.

Read More
Changing the Default Editor for Batch Files in Windows 11's File Explorer

Resolve the issue of batch files opening in Notepad by changing the default editor to a preferred application like VS Code.

Read More
Gain WiFi Connection Minutes Before Losing it by Changing MAC Address

Bypass MAC address filtering to restore WiFi connectivity temporarily when a device is blocked by network administrators.

Read More
Photos Folders Turned Black: Troubleshooting Picture Applications on Windows

Resolve black screens in Windows Photos by resetting the app, updating graphics drivers, and repairing system files.

Read More
Troubleshooting High CPU Temperature Values: A Step-by-Step Guide

Resolve high CPU temperatures and thermal throttling by monitoring with Speedfan, cleaning dust from cooling components, and replacing degraded thermal paste.

Read More
Make cURL establish TLS connection with CA unknown

Resolve cURL TLS connection failures with unknown or self-signed certificates by using the --insecure flag to bypass CA validation.

Read More
Troubleshooting Incorrect Network Metrics Values in Grafana, Prometheus, InfluxDB, and Telegraf

Fix incorrect network metrics in Grafana, Prometheus, InfluxDB, and Telegraf by verifying interface selection, resolving unit mismatches, and handling counter resets.

Read More
Start Another Terminal Window (cmd.exe) Windows Repair/Troubleshoot

Provides step-by-step instructions to access the Windows Command Prompt via bootable media for advanced system repair and troubleshooting.

Read More
Thinkpad P1 Gen 6: Sudden Thunderbolt 3 Dock USB-C Charging Stopped Working

Resolve sudden Thunderbolt 3 dock USB-C charging and internet failure on ThinkPad P1 Gen 6 by updating firmware, resetting the dock, and adjusting power settings.

Read More
ASUS Windows 11 Laptop: Internet Connection Issue with Hotspot

Resolve ASUS Windows 11 laptop spinning wheel issue when connecting to mobile hotspot by resetting network stack, disabling IPv6, and adjusting power settings.

Read More
Developing iOS Project with Firebase: Logging in and Sending Push Notifications

Integrates Firebase to enable secure user authentication and push notifications in iOS applications.

Read More
Troubleshooting Bash Script with Suspected Issues of Spaces, Dashes, Filenames and Quoting

Resolve Bash script failures caused by word splitting, globbing, and special characters in filenames by applying proper quoting techniques.

Read More
Populating OneDrive Folder for Local Backup without Affecting Remote Files

Prevent OneDrive from deleting remote files during Windows reinstallation by unlinking the account or using symbolic links to isolate local data.

Read More
Force First Frame as Keyframe Without Re-encoding: A Quick Solution

Resolve inaccurate seeking and playback glitches by re-encoding video to ensure the first frame is a valid keyframe.

Read More
Find Information in Database Using WSL (Ubuntu) on Windows-10

Resolve database connection issues from WSL Ubuntu on Windows 10 by configuring client tools and network access to query remote or local servers.

Read More
Configuring a New Router with Different Networks: One Family, One Guest

Resolve IP conflicts and isolate guest traffic by configuring a second router with a distinct subnet via its WAN port.

Read More
Quickly Open Multiple Stock Websites with a Single Command

Solve the problem of manually opening multiple stock research websites by creating a single command to launch them simultaneously on Windows, macOS, or Linux.

Read More
Improved Adobe Acrobat Search Experience: Access Advanced Search with Ease

Access advanced search filters like case sensitivity and regex in Adobe Acrobat by clicking More Options in the Find bar.

Read More
Port Forwarding VM via OpenVPN: A Comprehensive Guide

Configure OpenVPN server and iptables to forward specific ports from VPN clients to a virtual machine's internal IP address.

Read More
Understanding Partitions in the 1980s: A Look Back at MS-DOS and Master Boot Record

Explains how the Master Boot Record and partition table enabled MS-DOS to manage multiple disk volumes on a single physical drive.

Read More
Windows 10 Enterprise: Keyboard Not Detected in Managed Organization with Admin Privileges

Resolve Windows 10 Enterprise keyboard detection failures caused by Group Policy restrictions, driver corruption, or USB enumeration errors.

Read More
Can't Find x86_64 Versions of Applications on MacOS arm64 (M1)

Resolve missing x86_64 app issues on M1 Macs by installing Rosetta 2 and reinstalling apps as universal binaries.

Read More
How to Hide Installation Source for an Android App

Manage Android app installation source visibility by using USB transfers or file managers to reduce browser traces and isolate data via work profiles.

Read More
Connecting Momentus 4200.2 ST9808210A Hard Drive via USB Cable

Resolve inability to access Seagate Momentus 4200.2 ST9808210A hard drive by connecting it via USB using a compatible SATA-to-USB adapter and configuring the disk in Windows.

Read More