Advertisement
Guest User

Untitled

a guest
Mar 22nd, 2017
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.49 KB | None | 0 0
  1. sshClient = paramiko.SSHClient()
  2. sshClient.connect('127.0.0.1', username='matt', password='password')
  3. channel = sshClient.get_transport().open_session()
  4. channel.get_pty()
  5. channel.invoke_shell()
  6.  
  7. while True:
  8. command = raw_input('$ ')
  9. if command == 'exit':
  10. break
  11.  
  12. channel.send(command + "n")
  13.  
  14. while True:
  15. if channel.recv_ready():
  16. output = channel.recv(1024)
  17. print output
  18. else:
  19. time.sleep(0.5)
  20. if not(channel.recv_ready()):
  21. break
  22.  
  23. sshClient.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement