title: switch to different user using fabric
body: <p>I recently started looking at fabric for remote deployment. I need to switch to a diff user (from the one that I login as) and am not able to figure it out. Is it even possible, if so how? My current user doesnt have <code>sudo</code> permissions. </p>
  
  <p>I tried changing following environment variables</p>
  
  <pre><code>env.sudo_prefix = "su newUser -c "
  env.sudo_prompt = "Password:"
  </code></pre>
  
  <p>But fabric does not wait for password input for 'newUser' and fails. </p>
  
  <pre><code>out: Password: 
  [oldUser@ec2-111-11-111-111.compute-1.amazonaws.com] out: su: incorrect password
  
  Fatal error: sudo() received nonzero return code 1 while executing!
  
  Requested: touch x
  Executed: su newUser -c  -u "root"  /bin/bash -l -c "cd /home/oldUser/upgrade &amp;&amp; touch x"
  
  Aborting.
  Disconnecting from oldUser@ec2-111-11-111-111.compute-1.amazonaws.com... done.
  </code></pre>
  
  <p>Update:</p>
  
  <p>As J.F. Sebastian suggested, <code>su newUser -c</code> works, but it prompts password for every command for every server, which kind of defeats the purpose of automation. Is there any way in Fabric to pass in same value based on prompt (in this case, its always <code>Password:</code>)</p>