<?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: mgmt_cli.exe in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210164#M8440</link>
    <description>&lt;P&gt;It is working now with:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;mgmt_cli.exe add user name "myuser" email "myuser@email.com" --session-id RIwXloOkVnDAzvpkIZCn0cMbu5bPT1gvyRt_I_iWBYM -m 10.1.1.101&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;mgmt_cli.exe publish --session-id RIwXloOkVnDAzvpkIZCn0cMbu5bPT1gvyRt_I_iWBYM -m 10.1.1.101&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should I use sessionID and -m 10.1.1.101 every time I run a command from Windows CMD? Or there is a way to bypass these?&lt;/P&gt;</description>
    <pubDate>Mon, 01 Apr 2024 09:05:13 GMT</pubDate>
    <dc:creator>Moudar</dc:creator>
    <dc:date>2024-04-01T09:05:13Z</dc:date>
    <item>
      <title>mgmt_cli.exe</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210159#M8438</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;I use an api-key to login instead of username and password:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="api7.JPG" style="width: 999px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/25121i279D1C5DBD9C73D3/image-size/large?v=v2&amp;amp;px=999" role="button" title="api7.JPG" alt="api7.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;but when try to run any command it asks me again about username and password:&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="api8.JPG" style="width: 999px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/25122iBD818FC38F88C1CA/image-size/large?v=v2&amp;amp;px=999" role="button" title="api8.JPG" alt="api8.JPG" /&gt;&lt;/span&gt;&lt;/P&gt;&lt;P&gt;is that a right reaction? Why should I state username and password when using api-key?&lt;/P&gt;&lt;P&gt;what do I miss here?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 08:15:14 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210159#M8438</guid>
      <dc:creator>Moudar</dc:creator>
      <dc:date>2024-04-01T08:15:14Z</dc:date>
    </item>
    <item>
      <title>Re: mgmt_cli.exe</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210161#M8439</link>
      <description>&lt;P&gt;You're missing passing the session-id to your call. If you don't do that, you need to authenticate again as it is a new session.&lt;/P&gt;
&lt;P&gt;Barring login, API calls require a session-id to tie it to an authenticated session or use the -r flag to run as root, which executes your call and immediately publishes your changes.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 08:48:38 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210161#M8439</guid>
      <dc:creator>Alex-</dc:creator>
      <dc:date>2024-04-01T08:48:38Z</dc:date>
    </item>
    <item>
      <title>Re: mgmt_cli.exe</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210164#M8440</link>
      <description>&lt;P&gt;It is working now with:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;mgmt_cli.exe add user name "myuser" email "myuser@email.com" --session-id RIwXloOkVnDAzvpkIZCn0cMbu5bPT1gvyRt_I_iWBYM -m 10.1.1.101&lt;/LI-CODE&gt;&lt;LI-CODE lang="markup"&gt;mgmt_cli.exe publish --session-id RIwXloOkVnDAzvpkIZCn0cMbu5bPT1gvyRt_I_iWBYM -m 10.1.1.101&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Should I use sessionID and -m 10.1.1.101 every time I run a command from Windows CMD? Or there is a way to bypass these?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 09:05:13 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210164#M8440</guid>
      <dc:creator>Moudar</dc:creator>
      <dc:date>2024-04-01T09:05:13Z</dc:date>
    </item>
    <item>
      <title>Re: mgmt_cli.exe</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210175#M8442</link>
      <description>&lt;P&gt;You can do a "-r true" with every invocation of mgmt_cli from the SMS only as a "one off" to avoid authenticating every time or having to provide a SID, however this is not recommended for bulk use as doing so will authenticate, make your single change and publish it all in one invocation.&amp;nbsp; Using "-r true" with dozens or hundreds of rapid invocations of mgmt_cli will not only be much slower than making your bulk changes and then publishing once at the end, in extreme cases it can slow down everyone's copy of the SmartConsole GUI to the point of being unusable, due to the propagation of so many session-based changes.&amp;nbsp; However this has been mostly rectified in later versions, see:&amp;nbsp;&lt;A id="link_2_643f50b18045b6_1_23d1f" class="page-link lia-link-navigation lia-custom-event" href="https://community.checkpoint.com/t5/Management/R80-20-MDS-Slow/m-p/63848?search-action-id=85476078593&amp;amp;search-result-uid=63848" target="_blank" rel="noopener"&gt;R80.20 MDS Slow&lt;/A&gt;&lt;/P&gt;
&lt;P&gt;If you are using mgmt_cli from a remote Windows or Linux system you must authenticate then provide the SID with each subsequent call.&amp;nbsp; Be sure to logout and deallocate your SID when complete, as in later versions there is a cap on total sessions that can be pending, and if you hit the limit things will start failing.&lt;/P&gt;
&lt;P&gt;All of the above is covered in the best practices section of the newly-updated &lt;A href="https://training-certifications.checkpoint.com/#/courses/Automation%20Specialist%20R81.20%20(CCAS)" target="_blank" rel="noopener"&gt;Check Point Certified Automation Specialist R81.20 class&lt;/A&gt;&amp;nbsp;now available worldwide from Check Point ATCs.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 13:41:47 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210175#M8442</guid>
      <dc:creator>Timothy_Hall</dc:creator>
      <dc:date>2024-04-01T13:41:47Z</dc:date>
    </item>
    <item>
      <title>Re: mgmt_cli.exe</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210177#M8443</link>
      <description>&lt;P&gt;When you call 'login', save the output to a file. On subsequent calls, add '-s &amp;lt;File&amp;gt;' to reference that session. You don't need the '--session-id &amp;lt;SID&amp;gt;' or the '-m &amp;lt;ComputerName&amp;gt;' in the subsequent calls if you use the '-s &amp;lt;File&amp;gt;'.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 13:53:55 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210177#M8443</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2024-04-01T13:53:55Z</dc:date>
    </item>
    <item>
      <title>Re: mgmt_cli.exe</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210181#M8445</link>
      <description>&lt;P&gt;Right the approach of storing the SID in a file works just fine, subject to some things to be aware of:&lt;/P&gt;
&lt;P&gt;1) There will be a filename collision if multiple scripts invoking mgmt_cli are executing at the same time.&amp;nbsp; The first script drops its SID into the file after authenticating (let's say sid.txt).&amp;nbsp; Another script fires up while the first one is still running and dumps its SID into the same filename, now the first script starts screwing up when it reads the wrong SID.&amp;nbsp; This can cause some very hard to diagnose, random-looking failures. Been there, done that, got the T-shirt.&lt;/P&gt;
&lt;P&gt;2) The SID is left lying around in a file; if the session was not properly logged out and SID deallocated, someone (or some script) might be able to use that SID when they should not.&lt;/P&gt;
&lt;P&gt;For those reasons, it is recommended to store the allocated SID in an environment variable (like $SID), which will automatically be deallocated when the script finishes, and can't be accidentally used beyond the scope of that one script.&amp;nbsp; Once again these types of best practices are in the new&amp;nbsp;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;A href="https://training-certifications.checkpoint.com/#/courses/Automation%20Specialist%20R81.20%20(CCAS)" target="_blank" rel="noopener noreferrer"&gt;Check Point Certified Automation Specialist R81.20 class.&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 14:26:19 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210181#M8445</guid>
      <dc:creator>Timothy_Hall</dc:creator>
      <dc:date>2024-04-01T14:26:19Z</dc:date>
    </item>
    <item>
      <title>Re: mgmt_cli.exe</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210189#M8446</link>
      <description>&lt;P&gt;For scripts meant to be run in a non-interactive way, I recommend using mktemp on Linux or New-TemporaryFile in PowerShell. Both result in a new file in your temporary directory with a name which does not overlap with any existing names:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;portNumber=$(api status | grep "APACHE Gaia Port" | awk '{print $NF}')
sessionFile=$(mktemp)
cmaName="Global"
mgmt_cli --port "${portNumber}" -d "${cmaName}" -r true login &amp;gt;"${sessionFile}"
...&lt;/LI-CODE&gt;
&lt;P&gt;Or in PowerShell:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Port = "443"
SessionFile = New-TemporaryFile
CmaName = "Global"
mgmt_cli.exe --port "${Port}" -d "${CmaName}" -m ... login ... &amp;gt;"${SessionFile}"&lt;/LI-CODE&gt;
&lt;P&gt;I haven't actually used the Windows mgmt_cli in PowerShell, so I'm not 100% sure those options will work as written. Specifically, the domain may need to be in the parameters after login instead of the '-d' flag.&lt;/P&gt;</description>
      <pubDate>Mon, 01 Apr 2024 15:25:24 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/mgmt-cli-exe/m-p/210189#M8446</guid>
      <dc:creator>Bob_Zimmerman</dc:creator>
      <dc:date>2024-04-01T15:25:24Z</dc:date>
    </item>
  </channel>
</rss>

