<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: How to create an user over https with Python - CBS220 ? in Switching</title>
    <link>https://community.cisco.com/t5/switching/how-to-create-an-user-over-https-with-python-cbs220/m-p/4672882#M529446</link>
    <description>&lt;P&gt;&lt;SPAN&gt;CBS220&amp;nbsp; - small business switch, i do not believe that you looking to run program works on these models&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;that feature you looking to do only possible on enterprise-grade switches, which run IOS or IOSXE (other side nexus)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 20 Aug 2022 23:45:00 GMT</pubDate>
    <dc:creator>balaji.bandi</dc:creator>
    <dc:date>2022-08-20T23:45:00Z</dc:date>
    <item>
      <title>How to create an user over https with Python - CBS220 ?</title>
      <link>https://community.cisco.com/t5/switching/how-to-create-an-user-over-https-with-python-cbs220/m-p/4672880#M529445</link>
      <description>&lt;P&gt;Hello,&lt;/P&gt;&lt;P&gt;I am using a Cisco Switch CBS220-16P-2G&lt;BR /&gt;It does not come with telnet or ssh enabled by default. Only https.&lt;BR /&gt;( I do not think that this switch is running Cisco IOS XE. )&lt;/P&gt;&lt;P&gt;I just got the switch and discovered the RESTCONF.&lt;BR /&gt;Because of this, i am building a Python script to automate some stuff.&lt;/P&gt;&lt;P&gt;First, i would like to create an admin user, for which i want to provide my ssh key.&lt;/P&gt;&lt;P&gt;Then enable the ssh service on the switch.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;So far, i have managed to modify the interfaces ( in this example, i am adding a description for gi 0/3):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;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)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have searched about RESTCONF, but the examples that i have found do not work on my device.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Any recommendations on how to automate the user creation and enabling the ssh service on the switch, over https , please?&lt;BR /&gt;Thank you&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 22:49:53 GMT</pubDate>
      <guid>https://community.cisco.com/t5/switching/how-to-create-an-user-over-https-with-python-cbs220/m-p/4672880#M529445</guid>
      <dc:creator>HalfMoonRising</dc:creator>
      <dc:date>2022-08-20T22:49:53Z</dc:date>
    </item>
    <item>
      <title>Re: How to create an user over https with Python - CBS220 ?</title>
      <link>https://community.cisco.com/t5/switching/how-to-create-an-user-over-https-with-python-cbs220/m-p/4672882#M529446</link>
      <description>&lt;P&gt;&lt;SPAN&gt;CBS220&amp;nbsp; - small business switch, i do not believe that you looking to run program works on these models&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;that feature you looking to do only possible on enterprise-grade switches, which run IOS or IOSXE (other side nexus)&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 20 Aug 2022 23:45:00 GMT</pubDate>
      <guid>https://community.cisco.com/t5/switching/how-to-create-an-user-over-https-with-python-cbs220/m-p/4672882#M529446</guid>
      <dc:creator>balaji.bandi</dc:creator>
      <dc:date>2022-08-20T23:45:00Z</dc:date>
    </item>
  </channel>
</rss>

