title: How to run script as another user without password?
body: <p>I have script.sh that must be run as user2.  However, this script can only be run under user1 in my application.</p>
  
  <p>I would like the following command to run:</p>
  
  <pre><code>su user2 -C script.sh
  </code></pre>
  
  <p>but be able to run without password.</p>
  
  <p>I also want this to be very restrictive, as in user1 can only run script.sh under user2 and nothing else.</p>
  
  <p>I've tried doing this with sudoers file and just got endlessly confused after hours of trying.</p>
  
  <p>If somebody can provide an explicit example of how this can be accomplished (instead of something generic like use sudoers), it would be greatly appreciated.</p>