7

I'd like to be able to su to another user to run a script with reduced permissions. Unfortunately I have to type the password in every time, is there a way to create a user without needing the password prompt?

2 Answers2

15

Try sudo.

Add the following to your sudoers file (by running visudo):

%you ALL= (restricted) NOPASSWD: ALL

where you is your username and restricted is your reduced privilege user.

You can then run commands as restricted without supplying a password:

sudo -u restricted whoami

You can also limit what commands can be executed via sudo by replacing the ALL at the end of the line with the command line you want to allow. See man sudoers for more information.

Jason Weathered
  • 750
  • 1
  • 6
  • 8
0

You can su to root, and then when you su to another user, the password is not required.

Brent
  • 22,219
  • 19
  • 68
  • 102