Skip to content

Instantly share code, notes, and snippets.

@cdot65
Created March 29, 2023 21:16
Show Gist options
  • Save cdot65/14e1c74b6af5869e0dadb015e15a3822 to your computer and use it in GitHub Desktop.
Save cdot65/14e1c74b6af5869e0dadb015e15a3822 to your computer and use it in GitHub Desktop.
ChatGPT update NTP server
# Import necessary libraries
from netmiko import ConnectHandler
# Define list of devices
devices = [
{
'device_type': 'cisco_ios',
'ip': '192.168.1.1',
'username': 'admin',
'password': 'password'
},
{
'device_type': 'cisco_ios',
'ip': '192.168.1.2',
'username': 'admin',
'password': 'password'
},
# Add more devices as needed
]
# Define NTP server(s)
ntp_server = '10.0.0.1'
# Loop through devices and configure NTP
for device in devices:
# Establish SSH connection
with ConnectHandler(**device) as net_connect:
# Send commands to set NTP server(s)
config_commands = ['ntp server ' + ntp_server]
output = net_connect.send_config_set(config_commands)
print(output)
# Close SSH connection
net_connect.disconnect()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment