Q:

Python - Pxssh - Getting an password refused error when trying to login to a remote server

I'm trying to use the pexpect module pxssh to log in into my one of my server. I get password refused. I think I know what it is the problem, but can't figure out how to fix it. The issue is that there is a welcome banner when I log in into the server(Changing the banner is not an option) and the pexpect get confuse. Here is my code:
import pxssh

ssh = pxssh.pxssh()
ssh.login('192.168.1.10', 'username', 'password')

I'm expecting a 'password:', but pxssh is expecting original_prompt='[#$]'and those are symbols and in the banner the are couple of '.'
Any help, I will appreciate. Thanks

A:

This error came for ssh is lock.so open the terminals and execute that command 
xxxx@toad:~$ rm .ssh/known_hosts

remove the known_hosts 
another options is you login in windows means check command prompt.
if you try to login in windows means  use for pexpect
child = pexpect.spawn('ssh tiger@172.16.0.190 -p 8888')
child.logfile = open("/tmp/mylog", "w")
print child.before
child.expect('.*Are you sure you want to continue connecting (yes/no)?')
child.sendline("yes")

child.expect(".*assword:")
child.sendline("tiger\r")
child.expect('Press any key to continue...')
child.send('\r')
child.expect('C:\Users\.*>')
child.sendline('dir')
child.prompt('C:\Users\.*>')

pxssh uses the shell prompt to synchronize output from the remote host. 
In order to make this more robust it sets the shell prompt to something more
unique than just $ or #. This should work on most Borne/Bash or Csh style
shells.
Refer
http://www.pythonforbeginners.com/code-snippets-source-code/ssh-connection-with-python/

