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)

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. Sometimes getting could not syncronize with original prompt. It's an intermittent issue i don't know how to tackle it. I tried setting sync_multiplier=5, didn't work. Is it due to slow network connection?

    ReplyDelete

Post a Comment

Popular posts from this blog

Securing the Pi-hole with fail2ban to prevent DNS Amplification attacks

Reduce (shrink) and resize raw disk at Proxmox

How to clean DB from old logs in Magento 1.x