title: how to interact with Paramiko's interactive shell session?
body: <p>I have some Paramiko code where I use the invoke_shell method to request an interactive ssh shell session on a remote server. Method is outlined here: <a href="http://docs.paramiko.org/en/2.1/api/channel.html#paramiko.channel.Channel.invoke_shell" rel="nofollow noreferrer">invoke_shell()</a></p>
  
  <p>Here's a summary of the pertinent code:</p>
  
  <pre><code>sshClient = paramiko.SSHClient()
  sshClient.connect('127.0.0.1', username='matt', password='password')
  channel = sshClient.get_transport().open_session()
  channel.get_pty()
  channel.invoke_shell()
  
  while True:
      command = raw_input('$ ')
      if command == 'exit':
          break
  
      channel.send(command + "\n")
  
      while True:
          if channel.recv_ready():
              output = channel.recv(1024)
              print output
          else:
              time.sleep(0.5)
              if not(channel.recv_ready()):
                  break
  
  sshClient.close()
  </code></pre>
  
  <p>My question is: is there a better way to interact with the shell? The above works, but it's ugly with the two prompts (the matt@kali:~$ and the $ from raw_input), as shown in the screenshot of a test run with the interactive shell. I guess I need help writing to the stdin for the shell? Sorry, I don't code much. Thanks in advance! <a href="https://i.stack.imgur.com/5gQtg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5gQtg.png" alt="enter image description here"></a></p>