Advertisement
Guest User

Untitled

a guest
Mar 18th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1.  
  2. import paramiko
  3. import getpass
  4. import re
  5.  
  6.  
  7. IP = 'xx.xx.xx.xx'
  8. USER = 'xxx'
  9. PASSWORD = 'xxx.
  10.  
  11. ssh = paramiko.SSHClient()
  12. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  13.  
  14.  
  15. def initiatessh():
  16. ssh.connect( IP, username=USER, password=PASSWORD)
  17.  
  18.  
  19. def grabsshdata():
  20. stdin, stdout, stderr = ssh.exec_command('pwd', timeout=60)
  21. print('command executed')
  22. data = re.sub(r'\s+', '\n', str(stdout.read(), 'UTF-8')).splitlines()
  23. list = [line for line in data if line != '\n']
  24. print('printing')
  25. print(list)
  26.  
  27.  
  28. print('connection')
  29. initiatessh()
  30. print('established')
  31. print('grabbing data')
  32. grabsshdata()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement