Guest User

Untitled

a guest
Dec 5th, 2018
238
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.54 KB | None | 0 0
  1. import ssh
  2. HOST='192.168.1.1'
  3. USER='root'
  4. PASSWORD='password'
  5. COMMAND='echo "Command worked"'
  6.  
  7. transport = ssh.Transport((HOST, 22))
  8. transport.connect(username=USER, password=PASSWORD)
  9.  
  10. print 'Disconnect network before continuing'
  11. import pdb; pdb.set_trace()
  12.  
  13. channel = transport.open_session()
  14. channel.set_combine_stderr(True)
  15. channel.exec_command(COMMAND)
  16.  
  17. output = ''
  18. while True:
  19.     buff = channel.recv(128 * 1024)
  20.     if len(buff) == 0:
  21.         break
  22.     else:
  23.         output += buff
  24.  
  25. exit_status = channel.recv_exit_status()
Add Comment
Please, Sign In to add comment