paramiko期望无法识别思科电话的提示

问题描述

我正在尝试与Cisco Phone的SSH控制台进行交互。它具有paramiko期望无法识别的辅助登录。

My Code Snippet:
objSsh = paramiko.SSHClient()
objSsh.set_missing_host_key_policy(paramiko.AutoAddPolicy())

# Begin SSH Connection
objSsh.connect(strPhoneIP,username=strSSHUserID,password=strSSHPassword)

objInteract = SSHClientInteraction(objSsh,timeout=60,display=True)
print("Got Past Expect Interaction Line")
objInteract.expect('.*log.*')

# I Never get this print statement,which is how I know I'm stuck on the preceding line.
# The connection just times out
print("Got Past Expect Login Line")
objInteract.send('debug')
objInteract.expect('.*Password.*')
objInteract.send('debug')

这是通过Putty交互式登录手机的样子(已删除一些项目)

login as: <redactedUID>
<redactedUID>@<redactedIP>'s password:
(none) login: debug
Password:
enter full mode




DEBUG>

通过在SSHClientIneraction行中将Display设置为True,并在Expect行之后设置一条print语句,我知道我要登录到Shell并获得“(无登录名)”行。但是我的脚本永远不会越过该行并发出发送行。这告诉我,paramiko无法识别我的Expect行。但是我看不到我的Regex无法正常工作的原因,只是超时。

这是外壳程序的输出:

Imported Modules successfully
Opened Connection to ScreenShot Successfully
SSH Object Connected Successfully
Got Past Expect Interaction Line
(none) login: Traceback (most recent call last):
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\sit
e-packages\paramiko\channel.py",line 699,in recv
    out = self.in_buffer.read(nbytes,self.timeout)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\sit
e-packages\paramiko\buffered_pipe.py",line 164,in read
    raise PipeTimeout()
paramiko.buffered_pipe.PipeTimeout

During handling of the above exception,another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Administrator\Documents\PythonScripts\PhoneControl\ImageFromPho
neTest.py",line 121,in <module>
    objInteract.expect('.*log.*')
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\sit
e-packages\paramiko_expect.py",line 144,in expect
    current_buffer = self.channel.recv(self.buffer_size)
  File "C:\Users\Administrator\AppData\Local\Programs\Python\Python38-32\lib\sit
e-packages\paramiko\channel.py",line 701,in recv
    raise socket.timeout()
socket.timeout

有人知道我为什么要打这个吗?

FWIW:我是Python的新手,但是RegEx的中级。所以请ELI5。

谢谢!

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)

相关问答

错误1:Request method ‘DELETE‘ not supported 错误还原:...
错误1:启动docker镜像时报错:Error response from daemon:...
错误1:private field ‘xxx‘ is never assigned 按Alt...
报错如下,通过源不能下载,最后警告pip需升级版本 Requirem...