Quantcast
Channel: THWACK: All Content - Network Configuration Manager
Viewing all articles
Browse latest Browse all 6057

Need help with NCM Password Change Script/Template

$
0
0

Hi All,

 

I am trying to update the credentials of an emergency username and password for all of my IOS devices. I have 2 problems currently:

 

1.) NCM logs into my test device and starts to execute the script. Once finished, NCM through the web console shows "Connection Refused".

2.) After I decrypt my Cisco passwords in the config, intermittently, 2-3 of the passwords that are changed, have characters replaced with multiple question marks. For example, if my password is "PopTart5!", the password is actually reading as "PopTar???" after I decrypt it. Sometimes It will only have 1 ? mark at the end instead, so it isnt quite consistent.

 

I am currently running NCM 7.4. Below is the template I have taken from online and modified to fit my needs. Any idea what is going on here?

 

 

/*

.CHANGE_TEMPLATE_DESCRIPTION

        Updates the passwords redentials on Cisco IOS and NX-OS devices. 

.CHANGE_TEMPLATE_TAGS

        Cisco, Nexus, NX-OS, Password,

.PLATFORM_DESCRIPTION

        Cisco IOS, NEXUS

 

.PARAMETER_LABEL @ContextNode

        NCM Node

.PARAMETER_DESCRIPTION @ContextNode

        The node the template will operate on.  All templates require this by default. The target node is selected during the first part of the wizard so it will not be available for selection when defining values of variables.

 

.PARAMETER_LABEL @EmergencyUsername

        Local Emergency Username

.PARAMETER_DESCRIPTION @EmergencyUsername

        Enter the Emergency Username for the device(s).

 

 

.PARAMETER_LABEL @EmergencyPassword

        Local Emergency User Password

.PARAMETER_DESCRIPTION @EmergencyPassword

        Enter the new Emergency User password for the device(s).

 

 

.PARAMETER_LABEL @EnablePassword

        Enable Password

.PARAMETER_DESCRIPTION @EnablePassword

        Enter the new enable password for the device(s).

 

 

.PARAMETER_LABEL @ConsolePassword

        Console Password

.PARAMETER_DESCRIPTION @ConsolePassword

        Enter the new Console password for the device(s).

 

 

.PARAMETER_LABEL @VTYPassword

        VTY Password

.PARAMETER_DESCRIPTION @VTYPassword

        Enter the new VTY password for the device(s).

 

 

*/

 

 

script UpdateSNMPandPasswordCisco    (

                                         NCM.Nodes @ContextNode,

                                         string @EmergencyUsername,

                                         string @EmergencyPassword,

                                         string @EnablePassword,

                                         string @ConsolePassword,

                                         string @VTYPassword

)

{

  // Only select Cisco devices

  foreach ( @node in @ContextNode )

  {

     if ( @node.SysDescr Contains 'NX-OS(tm) n' )

//ONLY SELECT NX-OS DEVICES

    {

    // Set or update NEXUS Emergency User and Password

      CLI

      {

configure terminal

username admin password 0 @EmergencyPassword role network-admin

      }

    }

     if (@node.SysDescr contains 'ucs' )

// Do nothing if UCS device

    {

    }

     if (@node.SysDescr contains 'IOS' )

// ONLY SELECT IOS DEVICES

    {

      // Enter configuration mode

      CLI

      {

configure terminal

      }

      // Set or update enable Password

      CLI

      {

enable secret 0 @EnablePassword

      }

      // Set or update Emergency User and Password

      CLI

      {

username @EmergencyUsername privilege 0 secret 0 @EmergencyPassword

      }

      // Set or update Console Password

      CLI

      {

line con 0

password 0 @ConsolePassword

      }

      // Set or update VTY Password

      CLI

      {

line VTY 0 4

password 0 @VTYPassword

exit

line VTY 5 15

password 0 @VTYPassword

exit

      }

      // Exit configuration mode and write config

      CLI

      {

exit

copy run start

startup-config

      }

    }

  }

}


Viewing all articles
Browse latest Browse all 6057

Trending Articles