Netmiko 自动进入 CONF T!带 ASA 交换机

问题描述 投票:0回答:2

这个问题让我睡不着觉!请帮忙! 我想要的只是:连接到 Cisco-ASA,然后进入启用模式,然后显示接口状态

问题是,以下代码将进入启用模式,然后自动进入我不需要的 CONF t 模式。我需要它停止在启用模式。

def device1():

    checkOnline = {
        "device_type": "cisco_asa",
        "host": (swich1),
        "username": username,
        "password": password,
        'secret': password,
        'verbose': False,
        "session_log": 'dmz1_output.txt',
    }



    with ConnectHandler(**checkOnline) as net_connect:
        net_connect.enable()
        out1 = net_connect.send_command("show interface detail", use_textfsm=True)
        print(out1)

这是日志:

Failed logins since the last login: 0.  
Type help or '?' for a list of available commands.
Switch1/sec/actNoFailover> show curpriv
Current privilege level : 1
Current Mode/s : P_UNPR
Switch1/sec/actNoFailover> 
Switch1/sec/actNoFailover> 
Switch1/sec/actNoFailover> 
Switch1/sec/actNoFailover> 
Switch1/sec/actNoFailover> 
Switch1/sec/actNoFailover> 
Switch1/sec/actNoFailover> 
Switch1/sec/actNoFailover> 
Switch1/sec/actNoFailover> enable
Password: ************
Switch1/sec/actNoFailover# 
Switch1/sec/actNoFailover# terminal pager 0
Switch1/sec/actNoFailover# 
Switch1/sec/actNoFailover# configure terminal
Switch1/sec/actNoFailover(config)# 
Switch1/sec/actNoFailover(config)# terminal width 511
python-3.x paramiko netmiko
2个回答
1
投票

此后应自动退出配置模式,即更改终端宽度后,Netmiko 将退出配置模式。或者,您可以将

allow_auto_change=False
设置为 ConnectHandler 的参数(然后它不会更改终端宽度)。

这是假设 Netmiko 3.4.0


0
投票

我也有同样的问题。对于“terminal pager 0”,应该不需要执行“conf t”。这可以直接在启用模式下设置,无需进入配置模式。

© www.soinside.com 2019 - 2024. All rights reserved.