我尝试访问只有从运行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):
上面的顺序很好 我错过了“终端长度0”,而脚本却一直这样
相关问题 更多 >
编程相关推荐