<?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 How to  decrypt remote-password from auth group in NSO Developer Hub Discussions</title>
    <link>https://community.cisco.com/t5/nso-developer-hub-discussions/how-to-decrypt-remote-password-from-auth-group/m-p/5128675#M8520</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created the an auth group and thru api query I can retrieve the auth group int he code&lt;/P&gt;&lt;P&gt;/restconf/data/tailf-ncs:devices/authgroups/group=&amp;lt;group-name&amp;gt; or use maapi&lt;/P&gt;&lt;P&gt;Now i get the encrypted remote-password how do i decrypt the remote password for use&lt;/P&gt;&lt;P&gt;Nisheeth&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 11 Jun 2024 18:39:48 GMT</pubDate>
    <dc:creator>nisheeth</dc:creator>
    <dc:date>2024-06-11T18:39:48Z</dc:date>
    <item>
      <title>How to  decrypt remote-password from auth group</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/how-to-decrypt-remote-password-from-auth-group/m-p/5128675#M8520</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have created the an auth group and thru api query I can retrieve the auth group int he code&lt;/P&gt;&lt;P&gt;/restconf/data/tailf-ncs:devices/authgroups/group=&amp;lt;group-name&amp;gt; or use maapi&lt;/P&gt;&lt;P&gt;Now i get the encrypted remote-password how do i decrypt the remote password for use&lt;/P&gt;&lt;P&gt;Nisheeth&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 18:39:48 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/how-to-decrypt-remote-password-from-auth-group/m-p/5128675#M8520</guid>
      <dc:creator>nisheeth</dc:creator>
      <dc:date>2024-06-11T18:39:48Z</dc:date>
    </item>
    <item>
      <title>Re: How to  decrypt remote-password from auth group</title>
      <link>https://community.cisco.com/t5/nso-developer-hub-discussions/how-to-decrypt-remote-password-from-auth-group/m-p/5128694#M8521</link>
      <description>&lt;P&gt;Hi &lt;a href="https://community.cisco.com/t5/user/viewprofilepage/user-id/1595502"&gt;@nisheeth&lt;/a&gt; ,&lt;BR /&gt;Thanks to NSO architecture, in most of the cases, you don't need to access the user credentials.&lt;BR /&gt;For exceptions, you need to use the maapi api to retrieve the nso cryptographic material, and then use nso low level decrypt procedure to have access to the clear password. &lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://developer.cisco.com/docs/nso/api/_ncs-maapi/#header-functions" target="_blank"&gt;https://developer.cisco.com/docs/nso/api/_ncs-maapi/#header-functions&lt;/A&gt;&lt;BR /&gt;&lt;CODE class="name flex"&gt;
&lt;SPAN&gt;def &lt;SPAN class="ident"&gt;install_crypto_keys&lt;/SPAN&gt;&lt;/SPAN&gt;(&lt;SPAN&gt;sock)&lt;/SPAN&gt;
&lt;/CODE&gt;&lt;/P&gt;
&lt;DIV class="desc"&gt;
&lt;P&gt;Copy configured DES3 and AES keys into the memory in the library.&lt;/P&gt;
&lt;P&gt;Keyword arguments:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;sock – a python socket instance&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;&lt;A href="https://developer.cisco.com/docs/nso/api/_ncs/#header-functions" target="_blank"&gt;https://developer.cisco.com/docs/nso/api/_ncs/#header-functions&lt;/A&gt;&lt;CODE class="name flex"&gt;&lt;BR /&gt;&lt;SPAN&gt;def &lt;SPAN class="ident"&gt;decrypt&lt;/SPAN&gt;&lt;/SPAN&gt;(&lt;SPAN&gt;ciphertext) ‑&amp;gt;&amp;nbsp;&lt;A title="str" href="https://docs.python.org/3/library/functions.html#func-str" target="_blank" rel="noopener"&gt;str&lt;/A&gt;&lt;/SPAN&gt;
&lt;/CODE&gt;&lt;/P&gt;
&lt;DIV class="desc"&gt;
&lt;P&gt;When data is read over the CDB interface, the MAAPI interface or received in event notifications, the data for the builtin types tailf:des3-cbc-encrypted-string, tailf:aes-cfb-128-encrypted-string and tailf:aes-256-cfb-128-encrypted-string is encrypted. This function decrypts ciphertext and returns the clear text as a string.&lt;/P&gt;
&lt;P&gt;Keyword arguments:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;ciphertext – encrypted string&lt;/LI&gt;
&lt;/UL&gt;
&lt;/DIV&gt;
&amp;nbsp;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In the following document you can find a code example.&lt;BR /&gt;&lt;A href="https://developer.cisco.com/docs/nso-guides-6.3/python-api-overview/#advanced-topics" target="_blank"&gt;https://developer.cisco.com/docs/nso-guides-6.3/python-api-overview/#advanced-topics&lt;/A&gt;&lt;/P&gt;
&lt;DIV class="example"&gt;
&lt;DIV class="example-title"&gt;Example&amp;nbsp;102.&amp;nbsp;Setting of configuration data using MAAPI&lt;/DIV&gt;
&lt;DIV class="example-contents"&gt;
&lt;PRE class="programlisting"&gt;&lt;STRONG class="hl-keyword"&gt;import&lt;/STRONG&gt; socket
&lt;STRONG class="hl-keyword"&gt;import&lt;/STRONG&gt; _ncs
&lt;STRONG class="hl-keyword"&gt;from&lt;/STRONG&gt; _ncs &lt;STRONG class="hl-keyword"&gt;import&lt;/STRONG&gt; maapi

sock_maapi = socket.socket()

maapi.connect(sock_maapi,
              ip=&lt;STRONG class="hl-string"&gt;&lt;EM style="color: red;"&gt;'127.0.0.1'&lt;/EM&gt;&lt;/STRONG&gt;,
              port=_ncs.NCS_PORT)

maapi.load_schemas(sock_maapi)

maapi.start_user_session(
                  sock_maapi,
                  &lt;STRONG class="hl-string"&gt;&lt;EM style="color: red;"&gt;'admin'&lt;/EM&gt;&lt;/STRONG&gt;,
                  &lt;STRONG class="hl-string"&gt;&lt;EM style="color: red;"&gt;'python'&lt;/EM&gt;&lt;/STRONG&gt;,
                  [],
                  &lt;STRONG class="hl-string"&gt;&lt;EM style="color: red;"&gt;'127.0.0.1'&lt;/EM&gt;&lt;/STRONG&gt;,
                  _ncs.PROTO_TCP)

maapi.install_crypto_keys(sock_maapi)


th = maapi.start_trans(sock_maapi, _ncs.RUNNING, _ncs.READ)

path = &lt;STRONG class="hl-string"&gt;&lt;EM style="color: red;"&gt;"/devices/authgroups/group{default}/umap{admin}/remote-password"&lt;/EM&gt;&lt;/STRONG&gt;
encrypted_password = maapi.get_elem(sock_maapi, th, path)

decrypted_password = _ncs.decrypt(str(encrypted_password))

maapi.finish_trans(sock_maapi, th)
maapi.end_user_session(sock_maapi)
sock_maapi.close()

&lt;STRONG class="hl-keyword"&gt;print&lt;/STRONG&gt;(&lt;STRONG class="hl-string"&gt;&lt;EM style="color: red;"&gt;"Default authgroup admin password = %s"&lt;/EM&gt;&lt;/STRONG&gt; % decrypted_password)&lt;/PRE&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;/DIV&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jun 2024 19:53:14 GMT</pubDate>
      <guid>https://community.cisco.com/t5/nso-developer-hub-discussions/how-to-decrypt-remote-password-from-auth-group/m-p/5128694#M8521</guid>
      <dc:creator>Daniel Kratz</dc:creator>
      <dc:date>2024-06-11T19:53:14Z</dc:date>
    </item>
  </channel>
</rss>

