【发布时间】:2020-03-06 14:39:36
【问题描述】:
我正在尝试进行自动部署,该部署将提供给设备的远程配置,但我不知道出了什么问题。
我不是专家,只是学习 Python 的初学者。
我的设置。
PythonServer--ssh-> Cisco Console Server --reverse 原则 --> New_device(cisco)
我可以成功连接到 cisco colse 服务器。 (简单的部分,我可以使用 device_type 作为 'cisco_ios'、'cisco_ios_telnet'、terminal_server'、'generic_terminal_server' 进行连接)所有这些都可以工作。
当我尝试反向 telnet 时,我只收到密码提示。
************************************************************************
This is a privately owned computing system. Access permitted only by
authorized employees.
************************************************************************
Password:
我无法克服这一点。这是我的代码。我究竟做错了什么? (我认为这与 netmiko 处理连接的方式有关)有人可以帮我解决这个问题。
import time
from netmiko import ConnectHandler, redispatch
conserver_username = 'cisco'
conserver_password = 'cisco'
conserver_ip = '10.88.77.152'
console_server = {
'host': conserver_ip,
'username': conserver_username,
'password': conserver_password,
'device_type': 'cisco_ios',
'session_log': 'log.out'
}
net_connect = ConnectHandler(**console_server)
net_connect.send_command('\n', expect_string=r'#')
net_connect.send_command('telnet 10.88.77.152 2004', expect_string=r':')
net_connect.send_command_timing('cisco')
#net_connect.send_command_timing('cisco')
net_connect.send_command_timing('\n')
这会用横幅提示我,但不会继续。
我相信该模块会查找用户名,但由于它没有显示用户名,因此不知道如何处理它。
【问题讨论】:
标签: python network-programming netmiko