title: Execute remote commands as root using Python and paramiko
body: <p>Currently I'm working on a Python script to run embed shell scripts, the OS contain <em>root</em> and <em>normal_user</em>.</p>
  
  <p>The problem is, when I try to switch from <em>normal_user</em> to <em>root</em>, using a single command in one line.</p>
  
  <p>I have to only modify the code and nothing like <code>visudo</code> to achieve this and use <code>su</code> only without giving the <em>normal_user</em> any rights outside the coding .</p>
  
  <p>How can I achieve this?</p>
  
  <pre><code>ssh = paramiko.SSHClient()
  ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  ssh.connect('172.16.x.x', username='my_name', password='my_password')
  
  ***stdin, stdout, stderr = ssh.exec_command('switch to root user &amp;&amp; execute a commands as root')***
  
  
  stdin.flush()
  print stdout.readlines()
  ssh.close()
  </code></pre>