Reply

Python script to copy NX-OS config to scp server

[ Edited ]
New Member
Posts: 1
4003     1

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')

Re: Python script to copy NX-OS config to scp server

[ Edited ]
Superuser
Posts: 115
4004     1

So sorry about this late reply, I missed it

 

Try using this method instead

 

easy.send_command('copy startup-config scp://' + scp_user +':' + scp_pass + '@10.0.0.1/ \r\r\r')
Follow me on LinkedIn: https://www.linkedin.com/in/sifbaksh
Twitter: https://twitter.com/sifbaksh

https://sifbaksh.com

Re: Python script to copy NX-OS config to scp server

New Member
Posts: 1
4004     1

@SBaksh wrote:

So sorry about this late reply, I missed it

 

Try using this method instead

 

easy.send_command('copy startup-config scp://' + scp_user +':' + scp_pass + '@10.0.0.1/ \r\r\r')

Thank you very much for the explanation.

Showing results for 
Search instead for 
Did you mean: 

Recommended for You