Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
linux:sudo [2007/01/02 01:14]
a created
linux:sudo [2009/05/25 00:35] (current)
Line 1: Line 1:
 +====== SUDO tips and tricks ======
 +
 +
    username ALL=PASSWD: ALL; NOPASSWD: /usr/bin/ssh    username ALL=PASSWD: ALL; NOPASSWD: /usr/bin/ssh
  
Line 5: Line 8:
    foo       ALL=(ALL) NOPASSWD: ALL    foo       ALL=(ALL) NOPASSWD: ALL
  
 +===== How do I run a script as a certain user when it is called by another user with sudo? =====
 +
 +
 +
 +If a script that has been written needs to be run as a particular user, the /etc/sudoers file needs to be modified to include default user options.
 +
 +Edit the /etc/sudoers file by invoking:
 +
 +   #visudo
 +
 +In this example, SCRIPT1 is the script that will be executed. TESTUSER is the alias of users who have permission to execute the script via sudo and test is the user that the script must be run as.
 +
 +   Cmnd_Alias SCRIPT1=/bin/blah.sh
 +   User_Alias TESTUSER=test,test1,test2
 +   Defaults:TESTUSER runas_default=test
 +   TESTUSER ALL=NOPASSWD: SCRIPT1
 +
 +If the sudo /bin/blah.sh command is invoked by the test, test1, or test2 users it will run as user test. 
linux/sudo.1167696893.txt.gz ยท Last modified: 2009/05/25 00:34 (external edit)
CC Attribution-Share Alike 4.0 International
Driven by DokuWiki Recent changes RSS feed Valid CSS Valid XHTML 1.0 ipv6 ready