title: How do you execute multiple commands in a single session in Paramiko? (Python)
body: <pre><code>def exec_command(self, command, bufsize=-1):
      #print "Executing Command: "+command
      chan = self._transport.open_session()
      chan.exec_command(command)
      stdin = chan.makefile('wb', bufsize)
      stdout = chan.makefile('rb', bufsize)
      stderr = chan.makefile_stderr('rb', bufsize)
      return stdin, stdout, stderr
  </code></pre>
  
  <p>When executing a command in paramiko, it always resets the session when you run exec_command.
  I want to able to execute sudo or su and still have those privileges when I run another exec_command.
  Another example would be trying to exec_command("cd /") and then run exec_command again and have it be in the root directory. I know you can do something like exec_command("cd /; ls -l"), but I need to do it in separate function calls.</p>