Advertisement
Guest User

Untitled

a guest
Jul 23rd, 2014
204
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.26 KB | None | 0 0
  1. try:
  2. ssh_handle = pxssh.pxssh(timeout=None)
  3. ssh_handle.logfile = sys.stdout
  4. ssh_handle.login(host, username, password)
  5. index = ssh_handle.expect(['Are you sure you want to continue connecting (yes/no)? ', '.*?password:.*', '.*?$.*'])
  6. if index == 0:
  7. ssh_handle.sendline('yes')
  8. ssh_handle.sendline(password)
  9. if index == 1:
  10. ssh_handle.sendline(password)
  11. ssh_handle.sendline('sudo -s')
  12. ssh_handle.sendline(password)
  13. return ssh_handle
  14. except pxssh.ExceptionPxssh as e:
  15. print "SSH connection to %s failed" % host
  16. sys.exit()
  17.  
  18. File "/usr/lib/python2.7/dist-packages/pexpect/pxssh.py", line 313, in login
  19. if not self.sync_original_prompt(sync_multiplier):
  20. File "/usr/lib/python2.7/dist-packages/pexpect/pxssh.py", line 205, in sync_original_prompt
  21. b = self.try_read_prompt(sync_multiplier)
  22. File "/usr/lib/python2.7/dist-packages/pexpect/pxssh.py", line 168, in try_read_prompt
  23. prompt += self.read_nonblocking(size=1, timeout=timeout)
  24. File "/usr/lib/python2.7/dist-packages/pexpect/__init__.py", line 919, in read_nonblocking
  25. raise EOF('End Of File (EOF). Exception style platform.')
  26. pexpect.EOF: End Of File (EOF). Exception style platform.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement