Advertisement
Guest User

Untitled

a guest
Jul 7th, 2017
98
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import paramiko
  2. from paramiko_expect import SSHClientInteraction
  3.  
  4.  
  5. class Connection:
  6. def __init__(self):
  7. self.client = paramiko.SSHClient()
  8. self.client.load_system_host_keys()
  9. self.client.set_missing_host_key_policy(paramiko.AutoAddPolicy)
  10. self.client.connect(hostname='192.168.1.24', username='ozcan', password='ozcan')
  11.  
  12. self.interact = SSHClientInteraction(self.client, timeout=10, display=True,
  13. tty_width=100, tty_height=100)
  14. self.abc = self.interact
  15.  
  16. @staticmethod
  17. def get_interact(instance):
  18. return instance.interact
  19.  
  20.  
  21. qwe = Connection.get_interact(Connection())
  22. qwe.expect(r'.*\$\s+')
  23. qwe.send('ls')
  24. qwe.expect(r'.*\$\s+')
  25. qwe.take_control()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement