title: SSH from my local machine to linux host and sudo to root user
body: <p>Used subprocess to ssh to host. </p>
  
  <p>Here is the code snippet i used to ssh and run commands as my user. When i try to use sudo command i get error related to tty -- not a terminal (something like that)</p>
  
  <pre><code> sshProcess = subprocess.Popen(['ssh', hostname], stdin=subprocess.PIPE, stdout = subprocess.PIPE, universal_newlines=True, bufsize=0)
  sshProcess.stdin.write("hostname\n")
  sshProcess.stdin.write("ls -ldr %s \n"%path)
  sshProcess.stdin.write("pwd \n")
  sshProcess.stdin.close()
  for line in sshProcess.stdout:
   if line == "END\n":
   break
   print(line,end="")
  </code></pre>
  
  <p>But i am not able to run below command</p>
  
  <pre><code>sshProcess.stdin.write("sudo su - serviceuser \n")
  </code></pre>