Guest User

Untitled

a guest
Oct 3rd, 2018
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.47 KB | None | 0 0
  1. command = 'rpm -qa'
  2.  
  3. pkgList = []
  4.  
  5. client = paramiko.SSHClient()
  6.  
  7. client.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  8.  
  9. try:
  10.  
  11. client.connect('ipaddress', username='user', password='pwd')
  12.  
  13. except SSHException as error:
  14.  
  15. print (str(error) + "n"+ "Authentication error")
  16.  
  17. else:
  18.  
  19. stdin, stdout, stderr = client.exec_command(command)
  20.  
  21. for line in stdout:
  22.  
  23. pkgList.append(line.strip('n'))
  24.  
  25. for line in stderr:
  26.  
  27. print('' + line.strip('n'))
Add Comment
Please, Sign In to add comment