Skip to Content

Access denied for user root by PAM account configuration

fatal : Access denied for user root by PAM account configuration [preauth]


This error indicates issues with the PAM (Pluggable authentication module) configuration on your SSH server.

In the error log based on the distribution(O.S.) you are using; this would be the following error that you would receive.

You will not be able to log in to the remote server that has PAM misconfigurations. Following would be the error that would be received when you try to log in to the remote server that has existing PAM misconfigurations.

This issue could be solved with the following steps where you would set UsePam to no in sshd conf file which means that the SSH server will not use the PAM for user authentication.

Run the following command and restart the sshd service:

root@gateway:~# sudo sed -i 's/^UsePAM .*/UsePAM no/' /etc/ssh/sshd_config

root@gateway:~# systemctl restart sshd

And try to re-login to the remote server.


NOTE:

Even if we've resolved the immediate issue by setting UsePAM to "no," consider revisiting the PAM configuration, verifying the paths and permissions of the modules mentioned in the error messages, and making the necessary corrections. This ensures that your system is configured securely while allowing for proper authentication.


For Reference: https://arlimus.github.io/articles/usepam/