ccie50268
ccie50268

Reputation: 83

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. 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:[email protected]/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. Maybe because the input is hidden (it's a password) Netmiko can't pick up the input? Session log:

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? 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.

Upvotes: 0

Views: 2994

Answers (1)

ccie50268
ccie50268

Reputation: 83

I just discovered the cmd_verify=False option. I did this:

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

and it works fine now

Upvotes: 0

Related Questions