08-20-2022 03:49 PM
Hello,
I am using a Cisco Switch CBS220-16P-2G
It does not come with telnet or ssh enabled by default. Only https.
( I do not think that this switch is running Cisco IOS XE. )
I just got the switch and discovered the RESTCONF.
Because of this, i am building a Python script to automate some stuff.
First, i would like to create an admin user, for which i want to provide my ssh key.
Then enable the ssh service on the switch.
So far, i have managed to modify the interfaces ( in this example, i am adding a description for gi 0/3):
import requests
import json
from pprint import pprint
from dotenv import load_dotenv, find_dotenv
import os
load_dotenv(find_dotenv())
CISCOU = os.environ.get("CISCOU")
CISCOP = os.environ.get("CISCOP")
device = {
"ip": "10.1.1.103",
"username": CISCOU,
"password": CISCOP,
"port": "443",
}
headers = {
"Accept" : "application/yang-data+json",
"Content-Type" : "application/yang-data+json",
}
payload = {
"ietf-interfaces:interface": [
{
"name": "gi3",
"description": "HELLO"
}
]
}
# retreive all details
url = f"https://{device['ip']}/restconf/data/ietf-interfaces:interfaces/interface"
print(url)
requests.packages.urllib3.disable_warnings()
response = requests.patch(url,
headers=headers,
data=json.dumps(payload),
auth=(device['username'],
device['password']),
verify=False)
print(response)
I have searched about RESTCONF, but the examples that i have found do not work on my device.
Any recommendations on how to automate the user creation and enabling the ssh service on the switch, over https , please?
Thank you
08-20-2022 04:45 PM
CBS220 - small business switch, i do not believe that you looking to run program works on these models
that feature you looking to do only possible on enterprise-grade switches, which run IOS or IOSXE (other side nexus)
Discover and save your favorite ideas. Come back to expert answers, step-by-step guides, recent topics, and more.
New here? Get started with these tips. How to use Community New member guide