title: what permissions should jenkins have to execute shell-commands without being insecure?
body: <p>I have a script (test.sh) on a local server, which works fine when executed in a terminal. The script removes a directory, and recreates a directory local. It then connects to a remote server using "ssh -i $private_key .." and copies a file there.</p>
  
  <p>When I execute this script in jenkins with </p>
  
  <pre><code>sh test.sh
  </code></pre>
  
  <p>it doesnt work. I get the following errors:</p>
  
  <pre><code>rm: .. Permission denied
  mkdir: .. Permission denied
  Warning: Identity file /.ssh/private_key not accessible: Permission denied.
  </code></pre>
  
  <p>Jenkins is on the same server as the script. </p>
  
  <p>I see that Jenkins is another user and cant do everything that I'm doing as root; how can I set the permissions without losing all security. Especially in case of the private_key, it would be silly to set the permissions to easy - it is currently set to 600 (read and write permission for the owner) and the owner is root.</p>