Transitioning between Linux user accounts or elevating to the root administrative shell using su or su - is a fundamental routine for server maintenance and DevOps management. However, entering the expected password frequently triggers the blunt terminal rejection: “su: Authentication failure”. This failure halts administrative tasks immediately. On modern Linux distributions (such as Ubuntu, Debian, CentOS, and Fedora), this error is rarely a simple typo. It is typically caused by locked root account defaults, strict Pluggable Authentication Module (PAM) security configurations, or wheel group restrictions. Understanding how PAM governs su allows you to restore administrative access securely.
Why Does ‘su: Authentication failure’ Occur in Linux?
The su (substitute user) utility interacts with system authentication layers and PAM security stacks. Key causes include:
- Locked Root Account by Default (Ubuntu / Debian): Ubuntu and its derivatives do not configure a root password during installation. The root account entry in
/etc/shadowis set to!or*, rendering directsu -authentication impossible. - Target Password vs User Password Confusion:
surequires the password of the target user (e.g. root), whereassudorequires the password of the current calling user. - PAM Wheel Group Restrictions: Security-hardened Linux systems enforce
pam_wheel.soin/etc/pam.d/su, restrictingsuaccess exclusively to users explicitly listed in thewheeladministrative group. - Shadow File Permissions or SELinux Restrictions: Incorrect permissions on
/etc/shadowor SELinux security context denials blockingsusetuid root capabilities.
Step 1: Use ‘sudo -i’ or ‘sudo su -‘ Instead of Bare ‘su’
On distributions where the root account has no assigned password, elevate privileges through sudo using your personal administrator password.
- In your terminal window, execute:
(Alternatively, runsudo -isudo su -) - When prompted for
[sudo] password for user:, enter your current user’s password, not the root password. - If your user is in the
sudoorwheelgroup, you will immediately receive an interactive root login prompt (root@hostname:~#).
Step 2: Set or Unlock the Root Account Password
If your workflow explicitly requires direct su - access, assigning a password to the root user unlocks the account in /etc/shadow.
- Execute the password change command using your sudo privileges:
sudo passwd root - Type a strong, unique root password and press Enter.
- Retype the password to confirm.
- Now test switching to root directly using
su:su - - Enter the root password you just configured. The shell will switch immediately.
Step 3: Audit PAM Configuration and Add User to Wheel Group
On enterprise systems (such as RHEL, Rocky Linux, or AlmaLinux), the PAM security stack may strictly reject users who do not belong to the wheel group.
- Elevate using
sudoand inspect the PAM configuration forsu:sudo nano /etc/pam.d/su - Look for the line:
auth required pam_wheel.so use_uid - If this line is active (uncommented), only members of the
wheelgroup can executesu. - Add your standard user account to the
wheelgroup:
(On Ubuntu/Debian, usesudo usermod -aG wheel $USERsudo usermod -aG sudo $USER) - Log out of your SSH session or terminal session and log back in for group membership changes to take effect.
Step 4: Verify File Permissions and Setuid Flags on the ‘su’ Binary
The /bin/su binary must possess the setuid permission bit (-rwsr-xr-x) so that it can temporarily execute with root capabilities to verify hashes against /etc/shadow.
- Check the file permissions of the
subinary:ls -l /bin/su - The output must look like:
-rwsr-xr-x 1 root root ... /bin/su - If the
sflag is missing (e.g.-rwxr-xr-x), restore the setuid bit:sudo chmod u+s /bin/su - Verify that
/etc/shadowhas secure000or640permissions owned byroot:shadow:sudo chmod 640 /etc/shadow sudo chown root:shadow /etc/shadow