Azure

Azure AD Linux Login Extension – sudo fails with PAM account management error: System error

1 min read

As you all know, I’ve been playing around with the Azure Active Directory login extensions for both Linux and Windows. I came across a problem where the first sudo worked (after re-authenticating) and the second, with the same command, failed with

sudo: PAM account management error: System error

Trying to debug this was tricky. Along with a support engineer we were able to enable enough log to get to the bottom of the problem.

First, edit /etc/pam.d/system-auth-aad and add the debug keyword whenever you see pam_aad.so. Adding “debug” will switch to verbose logging.

For example:

Once that is done, execute in one terminal the following command tail -f /var/log/secure. Execute the sudo that you know will fail (that is the second one after re-authenticating) in a second terminal.

You should see some output like

As you can see from the logs, Managed Identity needs to be enabled on the virtual machine for the extension to work properly. Unfortunately, this is not documented in the official documentation. I’ve opened a GitHub issue for them to update it.

UPDATE 2021-06-01: The AADLoginForLinux is being deprecated on 2021-08-15. Please use the new extension, SSH based, AADSSHLoginForLinux.