title: Fabric: do everything as a particular user
body: <p>My build and production deployment is connected using a keys by one user particular user that is shared across deployment and keys copied over during the machine spin up.</p>
  
  <p>This user <strong>deploy</strong>, has ssh keys shared allowing ssh to any prod machine and between them.  </p>
  
  <p>Now my fabric build runs as user <strong>Jenkins</strong>.  </p>
  
  <p>How do I instruct fabric to execute everything as a particular user(<strong>deploy</strong> in this case)?The equivalent of <code>sudo su deploy</code>  </p>
  
  <p>I don’t want to do a <code>prefix</code> or <code>with</code> in every task. Rather set a global variable.   </p>
  
  <p>Jenkins is in the wheel group and has sudo perms</p>