Python 使用pxssh时出现读取非阻塞错误

Python 使用pxssh时出现读取非阻塞错误,python,ssh,pexpect,Python,Ssh,Pexpect,我正在尝试在我的机器上使用pxssh模块,使用python脚本执行ssh。我降落在 Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/lib/python2.6/dist-packages/pxssh.py", line 243, in login if not self.synch_original_prompt():

我正在尝试在我的机器上使用pxssh模块,使用python脚本执行ssh。我降落在

    Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python2.6/dist-packages/pxssh.py", line 243, in login
    if not self.synch_original_prompt():
  File "/usr/local/lib/python2.6/dist-packages/pxssh.py", line 134, in synch_original_prompt
    self.read_nonblocking(size=10000,timeout=1) # GAS: Clear out the cache before getting the prompt
  File "/usr/local/lib/python2.6/dist-packages/pexpect.py", line 824, in read_nonblocking
    raise TIMEOUT ('Timeout exceeded in read_nonblocking().')
pexpect.TIME

OUT: Timeout exceeded in read_nonblocking().
产量为

ls -l
<class 'pexpect.TIMEOUT'>

你确定你可以从命令行使用ssh使用给定的凭据进行连接吗?@Pedro是的……我可以通过终端进行连接。问题只是在使用pexpect时出现的
ls -l
<class 'pexpect.TIMEOUT'>
import pxssh

def send_command(child,cmd):
    child.send(cmd)
    child.prompt()
    print child.before
    print child.after

def connect(host,user,pwd):   
    s = pxssh.pxssh()
    s.login(host,user,pwd,auto_prompt_reset=True)
    return s

def main():
    s = connect('127.0.0.1','root','*********')
    send_command(s, "ls -l")

if __name__ == "__main__":
    main()