Got it

Save configuration with Netmiko

Created: Jan 19, 2021 09:19:01Latest reply: Jan 20, 2021 10:07:15 3134 32 1 0 0
  Rewarded HiCoins: 0 (problem resolved)

Hi all

I configured some swithes with python using netmiko

but comand (Save) for save configuration doesnt work

any help ?

Featured Answers
chenhui
Admin Created Jan 20, 2021 08:59:45

Posted by aboyasir at 2021-01-20 06:58 same erroron cisco switches it works because i can save config with command (do wr ) in configuratio ...
Hi,
I found an alternative way to save the configuration. Please refer to the code below:
config_commands=[
'int loop0',
'ip add 10.2.1.1 32',
'return',
]
output=net_connect.send_config_set(config_commands)
net_connect.save_config('save') //save the configuration after sending the commands.
View more
  • x
  • convention:

All Answers
Hi,
Can you share your script?
View more
  • x
  • convention:

from netmiko import ConnectHandler

import time

import datetime


IP_List = open('IPs.txt')

for IP in IP_List:

    SWS = {

    'device_type': 'huawei',

    'ip': IP,

    'username': 'user',

    'password': 'Password',

    }


View more
  • x
  • convention:

 print ('\n ##### connection to device' + IP.strip() + '##### \n')

    net_connect = ConnectHandler(**SWS)

   

    config_commands = [ 'aaa',

                        'local-user user1 password cipher 0000000',

                        'local-user user1 privilege level 3',

                        'local-user user1 service-type ssh',

                        'quit',

                        'stelnet server enable',

                        'ssh user user1 authentication-type password',

                        'ssh user user1 service-type stelnet',

                        'user-interface vty 0 4',

                        'authentication-mode aaa',

                        'protocol inbound ssh']


View more
  • x
  • convention:

I put it in three parts because dont accept here in one part

the script works ok , but when add (return) or (save ) commands it gives error 

View more
  • x
  • convention:

Posted by aboyasir at 2021-01-19 10:13 I put it in three parts because dont accept here in one partthe script works ok , but when add (retu ...
Well, you just upload only two parts. And no error message. Can you please add the rest?
View more
  • x
  • convention:

output = net_connect.send_config_set(config_commands)
View more
  • x
  • convention:

print(output)
View more
  • x
  • convention:

untill here its ok
View more
  • x
  • convention:

I want to know how to add save command
View more
  • x
  • convention:

Comment

You need to log in to comment to the post Login | Register
Comment

Notice: To protect the legitimate rights and interests of you, the community, and third parties, do not release content that may bring legal risks to all parties, including but are not limited to the following:
  • Politically sensitive content
  • Content concerning pornography, gambling, and drug abuse
  • Content that may disclose or infringe upon others ' commercial secrets, intellectual properties, including trade marks, copyrights, and patents, and personal privacy
Do not share your account and password with others. All operations performed using your account will be regarded as your own actions and all consequences arising therefrom will be borne by you. For details, see " User Agreement."

My Followers

Login and enjoy all the member benefits

Login

Block
Are you sure to block this user?
Users on your blacklist cannot comment on your post,cannot mention you, cannot send you private messages.
Reminder
Please bind your phone number to obtain invitation bonus.