How do I allow only one user to su to another account?

I have user-a and user-b on my box.

How do I do a no-password su - user-b as user-a?


Solution 1:

su is not meant to do that -- sudo is.

Open /etc/sudoers.d/custom and write the following:

user-a ALL=(user-b:user-b) NOPASSWD:ALL

Which means: whenever user-a executes sudo -u user-b (or any other variant), let him go without asking for password.