简体   繁体   English

执行多行 SCP 文件复制时未检测到 Netmiko ReadTimeout 模式

[英]Netmiko ReadTimeout Pattern not detected performing multiline SCP file copy

I'm trying to use Netmiko to log into a Cisco NXOS device and copy its startup config to another NXOS device.我正在尝试使用 Netmiko 登录 Cisco NXOS 设备并将其启动配置复制到另一个 NXOS 设备。 Here's the script:这是脚本:

core1 = {"device_type":"cisco_nxos","host":"192.168.254.51","username":"admin","password":"admin"}
net_connect = ConnectHandler(**core1)
net_connect.enable()
cmds = [["copy start scp://admin:admin@192.168.254.55/my-backup.cfg vrf management",r"Password"],["admin",""]]
r = net_connect.send_multiline(cmds)
net_connect.disconnect()

The code seems to work, it actually copies the config, but after some delay (the timeout) it throws an exception:该代码似乎有效,它实际上复制了配置,但经过一些延迟(超时)后,它抛出了一个异常:

netmiko.exceptions.ReadTimeout: 

Pattern not detected: 'admin' in output.

I cannot figure out what I'm doing wrong.我无法弄清楚我做错了什么。 It says pattern "admin" not detected, but it definitely sent admin as the password.它说没有检测到模式“admin”,但它肯定发送了 admin 作为密码。 Maybe because the input is hidden (it's a password) Netmiko can't pick up the input?可能是因为输入是隐藏的(它是密码) Netmiko 无法获取输入? Session log: Session 日志:

Prod-CORE1# 
Prod-CORE1# terminal width 511
Prod-CORE1# terminal length 0

Prod-CORE1# 
Prod-CORE1# 
Prod-CORE1# 
Prod-CORE1# copy start scp://********:********@192.168.254.55/my-backup.cfg vrf management
Outbound-ReKey for 192.168.254.55:22
Inbound-ReKey for 192.168.254.55:22
User Access Verification

Password: 

Prod-CORE1-startup-config                                                                                                                                                                                                                                                                                                                                                                                                                                                                      0%    0     0.0KB/s   --:-- ETA
Prod-CORE1-startup-config                                                                                                                                                                                                                                                                                                                                                                                                                                                                    100% 5153   544.0KB/s   00:00    
Copy complete, now saving to disk (please wait)...
Copy complete.

Prod-CORE1# 
Prod-CORE1# exit

Is there a way to handle hidden inputs with Netmiko or send a "blind" command?有没有办法用 Netmiko 处理隐藏输入或发送“盲”命令? SCP copies on NXOS seem to ignore the username:password format and still prompt for a password so I can't run the copy on a single line. NXOS 上的 SCP 副本似乎忽略了用户名:密码格式,仍然提示输入密码,因此我无法在一行上运行副本。

I just discovered the cmd_verify=False option.我刚刚发现了 cmd_verify=False 选项。 I did this:我这样做了:

r = net_connect.send_multiline(cmds,cmd_verify=False)

and it works fine now现在工作正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM