Advertisement
Guest User

Untitled

a guest
Nov 26th, 2016
197
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.46 KB | None | 0 0
  1. import paramiko
  2.  
  3. ip='server ip'
  4. port=22
  5. username='username'
  6. password='password'
  7.  
  8. cmd='some useful command'
  9.  
  10. ssh=paramiko.SSHClient()
  11. ssh.set_missing_host_key_policy(paramiko.AutoAddPolicy())
  12. ssh.connect(ip,port,username,password)
  13.  
  14. stdin,stdout,stderr=ssh.exec_command(cmd)
  15. outlines=stdout.readlines()
  16. resp=''.join(outlines)
  17. print(resp)
  18.  
  19. stdin,stdout,stderr=ssh.exec_command('some really useful command')
  20. outlines=stdout.readlines()
  21. resp=''.join(outlines)
  22. print(resp)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement