Thursday, May 12, 2016

Python pxssh failed on login. could not set shell prompt

Python pxssh failed on login. could not set shell prompt 

probably pxssh cannot find right prompt so it is better to setup original prompt s.prompt() and don`t forget to setup auto_prompt_reset=False

from pexpect import pxssh
import getpass

try:
    s = pxssh.pxssh(timeout=60)
    s.force_password = True
    hostname = raw_imput('hostname: ')
    username = raw_input('password: ')
    password = getpass.getpass('password: ')
    s.PROMPT= 'SSH> ' #here is your original prompt
    s.login (hostname, username, password, auto_prompt_reset=False)
    s.prompt()
    s.sendline('show version') #your command is here
    s.prompt()
    data = s.before
    print data
    s.logout()
except pxssh.ExceptionPxssh, e:
    print "pxssh failed on login."
    print str(e)

10 comments:

  1. Thanks for your blog so much!!!

    ReplyDelete
  2. Thank you so much for your blog. It helped me ..

    ReplyDelete
  3. Thanks!! Ditto the others.

    ReplyDelete
  4. not worked for me still same error

    ReplyDelete
  5. error
    Could not establish connection to host

    ReplyDelete
  6. This comment has been removed by a blog administrator.

    ReplyDelete
  7. Wow! Such an amazing and helpful post this is. I really really love it. It's so good and so awesome. I am just amazed. I hope that you continue to do your work like this in the future also https://sites.google.com/site/hotmailloginonline/

    ReplyDelete
  8. I’m going to read this. I’ll be sure to come back. thanks for sharing. and also This article gives the light in which we can observe the reality. this is very nice one and gives indepth information. thanks for this nice article... hotmail email

    ReplyDelete
  9. In the event that you are a Facebook client and need to dispose of Facebook login issues, for example, phishing dangers or failed to remember secret key then you have to go in for secret phrase administrator, for example, Last Pass. www.hotmail.com

    ReplyDelete

Cybermap

Internet Storm Center Infocon Status

Internet Storm Center Infocon Status
Internet Storm Center Infocon Status