简体   繁体   中英

pxssh login issue to router cli interface

Hi i am trying to automate to get some data from ruckless wireless router.

I used the following code

 import pxssh
 s = pxssh.pxssh()
 s.login('192.168.2.100','admin','admin')

And when i try to login itself i am getting error

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib/python2.7/dist-packages/pexpect/pxssh.py", line 321, in login
   raise ExceptionPxssh ('could not set shell prompt\n'+self.before)
  pexpect.pxssh.ExceptionPxssh: could not set shell prompt

Please login: unset PROMPT_COMMAND
Password: 
Login incorrect

Please login: set prompt='[PEXPECT]\$ '
Password: 

And this is not a normal bash shell like linux. I guess it has its own embedded OS and their own shell.

How can i login and create a session. so that i can automate few tasks

Try to use paramiko ssh client for Python. It worked for me. You can use pip to install it.

apt-get install python-pip

pip install paramiko

Here you can find how to use:

http://www.minvolai.com/blog/2009/09/how-to-ssh-in-python-using-paramiko/

http://jessenoller.com/blog/2009/02/05/ssh-programming-with-paramiko-completely-different

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM