Exscript:通过堡垒主机访问远程网络设备,同时仍然使用特定于设备的驱动程序来识别设备promp

2024-05-29 07:51:45 发布

您现在位置:Python中文网/ 问答频道 /正文

我尝试访问只有从运行SunOS的bastion主机上ssh才能访问的网络设备(不支持proxycommand或ssh隧道)

我的方法是使用通用驱动程序访问bastion主机。然后使用“ssh remotedevicename”连接到远程设备。在

在我的情况下,远程设备只需要一步身份验证,这会让我进入#提示符(Cisco设备的15级访问权限)

我成功地进行了身份验证,但无法发送命令

这是我用的

conn = SSH2()  
conn.debug=5  
conn.set_driver('generic')          
conn.connect('bastion')  
conn.login(account)        
print conn.response
conn.send('ssh 1.1.1.1\n')
conn.expect('Password:')
print conn.response
conn.send('password\n')

在这一点上,我想我应该换个司机

^{pr2}$

但完成后,脚本超时

nxos: Sending 'show cdp neighbors\n\r'
nxos: Expecting a prompt
nxos: Expected pattern: ["'[\\\\r\\\\n][\\\\-\\\\w+\\\\.:/]+(?:\\\\([^\\\\)]+\\\\))?[>#] ?$'"]
Traceback (most recent call last):

Tags: 方法身份验证send远程response驱动程序connssh

热门问题