[sudo-users] Question on SUDO syntax

Todd C. Miller Todd.Miller at courtesan.com
Mon Apr 26 22:15:49 EDT 2010


In message <DB53C993E8765A439D0AD48940C633090C7BEAE3 at SXGM-303.fg.rbc.com>
	so spake "Gonzalez, Aliep" (aliep.gonzalez):

> What is the correct syntax in /etc/sudoers for running "sudo -i -u userB
> /path_to_scriptB" as userA without providing a password ?
> 
> I can get this to work but I am always prompted for userB's password,
> which is kind of inconvenient.
> 
> I would like to avoid  using "sudo su - userB -c /path_to_scriptB"  if
> possible.

The actual command will depend on what shell userB has in the
password database.  Assuming that is /bin/ksh, then the following
should work.

    userA ALL = (userB) NOPASSWD: /bin/ksh -c /path_to_scriptB

Or if there are command line arguments:

    userA ALL = (userB) NOPASSWD: /bin/ksh -c \"/path_to_scriptB arg1 ...\"

 - todd



More information about the sudo-users mailing list