I noticed with pam_aad in my Ubuntu 24.04 server that you need to login via GDM before your aad account is added to /var/lib/aad/cache/passwd.db and after that, you can ssh to the aad-enabled server. Also, no aad groups are recognized, but you can add your aad accounts to the local /etc/groups file if you like.
It seems (at least with my config) that sshd using pam_aad.so can't get the right credentials, while GDM can.
sshd[12625]: pam_aad(sshd:auth): aad auth debug enabled
sshd[12625]: pam_aad(sshd:auth): PAM AAD DEBUG enabled
sshd[12625]: pam_aad(sshd:auth): Loading configuration from /etc/aad.conf
sshd[12625]: pam_aad(sshd:auth): Connecting to "https://login.microsoftonline.com/(my tenant id)", with clientID "(my app_id)" for user "(my aad acccount)"
sshd[12625]: pam_aad(sshd:auth): Got response: Invalid credentials
The pam_aad logs for a successful GDM login show the same except after the "Connecting" line it says:
[gdm-password]: pam_aad(gdm-password:auth): Authentication successful even if requiring MFA
Also, in MS Entra admin center, I needed to:
- app registrations -> (your app) -> advanced settings: Allow public client flows
and then a reboot just in case.