title: Is it possible to "su" to a user from only a specific user without password?
body: <p>I have user A and user B on a CentOS7 system.</p>
  <p>I have full access to user B, but no access to user A. What I want is only from user A, one can su into user B without password. From any other user including ssh one must enter the password. Is this possible to achieve?</p>
  <p>To give some context, I am currently creating a Jenkins Job using &quot;Active Choices Parameter&quot;. But the Groovy script that generates the &quot;Active Choices Parameter&quot;s only runs as &quot;jenkins&quot; user while I need access to my &quot;personal&quot; user scripts on the system. Which means I have to &quot;su&quot; from the &quot;jenkins&quot; user into my &quot;personal&quot; user.</p>
  <p>As it currently stands I am using <code>echo &quot;password&quot; | su my_user -c &quot;some command&quot;</code> to achieve the effect, but since the script is viewable on the webpage and the Jenkins server is accessible by anyone in the same network, it implies my personal user password is viewable by anyone and people can do malicious thing to my custom account without me knowing.</p>
  <p>Is there a way to achieve the effect where I can switch from &quot;jenkins&quot; user to my user without the need to provide a password?</p>
  <p>If this is achievable, it is assumed all modification to Jenkins web scripts are monitored and no one will try to do malicious thing using the Jenkins web interface.</p>
  <p>The full Groovy script I am currently using is something like below</p>
  <pre><code>def cmd = [&quot;/bin/sh&quot;, &quot;-c&quot;, &quot;echo 'password' | su my_user -c 'cd &amp;&amp; ./custom.sh 2&gt;&amp;3' 3&gt;&amp;2 2&gt;/dev/null &quot;]
  def output = new StringBuilder(), error = new StringBuilder()
  def proc = cmd.execute()
  proc.consumeProcessOutput(output, error)
  proc.waitForOrKill(5000)
  if (!error) {
      List lines = output.toString().split( '\n' )
      return lines
  } 
  return []
  </code></pre>
  <p>The effect I want is such that there is no &quot;password&quot; showing up in the script.</p>