- Subscribe to RSS Feed
- Mark Topic as New
- Mark Topic as Read
- Float this Topic for Current User
- Bookmark
- Subscribe
- Printer Friendly Page
Python script to copy NX-OS config to scp server
[ Edited ]- Mark as New
- Bookmark
- Subscribe
- Subscribe to RSS Feed
- Permalink
- Email to a Friend
- Report Inappropriate Content
2 weeks ago - last edited 2 weeks ago
Hello,
My apologies if this has been answered before, I did a search and could not find anything. I’m trying to back up my configs to a SCP server. It works with IOS the issue is with NX-OS. When SCP I include the username and password in the command, however it still prompts for the password and times out. Is there a way to send the password in a different line? Here is my script.
Any help is much appreciated.
# BEGIN-SCRIPT-BLOCK
#
# Script-Filter:
# $vendor eq "Cisco"
#
#
# Script-Variables:
# $scp_user string "Network Username"
# $scp_pass password "Enter Password"
#
# Script-timeout:300
# END-SCRIPT-BLOCK
from infoblox_netmri.easy import NetMRIEasy
import re
# This values will be provided by NetMRI before execution
defaults = {
"api_url": api_url,
"http_username": http_username,
"http_password": http_password,
"job_id": job_id,
"device_id": device_id,
"batch_id": batch_id
}
# Create NetMRI context manager. It will close the session after execution
with NetMRIEasy(**defaults) as easy:
shover = easy.send_command('show version | inc IOS|Nexus')
pattern = re.compile(r'(IOS|Nexus)')
version = pattern.findall(shover)
print(version[0])
if(version[0] == 'IOS'):
easy.send_command('write memory')
easy.send_command('copy startup-config scp://{}:{}@10.0.0.1/ \r\r\r'.format(scp_user, scp_pass))
elif(version[0] == 'Nexus'):
easy.send_command('copy running-config startup-config')
easy.send_command('copy startup-config scp://{}:{}@10.0.0.1/ vrf default \r\r'.format(scp_user, scp_pass))
else:
print('This is not a switch or router')