Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import ssh
- HOST='192.168.1.1'
- USER='root'
- PASSWORD='password'
- COMMAND='echo "Command worked"'
- transport = ssh.Transport((HOST, 22))
- transport.connect(username=USER, password=PASSWORD)
- print 'Disconnect network before continuing'
- import pdb; pdb.set_trace()
- channel = transport.open_session()
- channel.set_combine_stderr(True)
- channel.exec_command(COMMAND)
- output = ''
- while True:
- buff = channel.recv(128 * 1024)
- if len(buff) == 0:
- break
- else:
- output += buff
- exit_status = channel.recv_exit_status()
Add Comment
Please, Sign In to add comment