HOME BLOG

How to be able to switch to another user without entering password

Posted on: September 17th, 2022 by Olu No Comments

Hi folks,

In this post I explain how to switch to another user in Linux without needing to enter a password.

You can do this with the PAM authentication module.

Edit /etc/pam.d/su

vim /etc/pam.d/su

 

Then enter the following lines

auth       [success=ignore default=1] pam_succeed_if.so user = the-username
auth       sufficient   pam_succeed_if.so use_uid user ingroup the-groupname

Save and exit the file.

This will allow you to switch to the-user if you belong to the-group without needing to enter the password for the user using a command like

 su - the-user

 

That’s all for now. Till next time, happy software engineering.

 

References

How to Switch (su) to Another User Account without Password. https://www.tecmint.com/switch-user-account-without-password/

Leave a Reply