<?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 Clishtory in API / CLI Discussion</title>
    <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Clishtory/m-p/164323#M7333</link>
    <description>&lt;P&gt;The following script can be run on a Gaia system to provide a log of all Clish entries from all users.&lt;/P&gt;&lt;P&gt;You can also use the script repository in Smart Console.&lt;/P&gt;&lt;P&gt;Observations:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The Clish history file is written upon logout of the session, so if a command crashes the system it could not be logged, nor does it log commands being entered by an active user&lt;/LI&gt;&lt;LI&gt;There's no timestamps that I know of for individual commands&lt;/LI&gt;&lt;LI&gt;The script will cycle through UID and collect the Clish history from each one. Some Check Point services have UID above 102 but don't use clish, so they will still appear in the report&lt;/LI&gt;&lt;LI&gt;I'm including the base64 below to use in your favourite launcher&lt;/LI&gt;&lt;LI&gt;Only tried on R81.10&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/bin/bash

echo "Clish history for $(hostname)"
printf "\n"

readarray -t user_index &amp;lt; &amp;lt;(cat /etc/passwd | awk -F: '{user_id=$3+0; if(user_id==0 || user_id &amp;gt; 102) {print $1}}' | grep -v root)
declare -p user_index &amp;gt;/dev/null

for i in ${user_index[@]}
do
if test -f /home/$i/.clish_history; then
echo "User $i, last modified on $(ls -l /home/$i/.clish_history | awk '{print $6, $7}')"
cat /home/$i/.clish_history
else
echo "No clish entries for user $i"
fi
printf "\n"
done&lt;/LI-CODE&gt;&lt;P&gt;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;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Clish history for &amp;lt;hostname&amp;gt;

User admin, last modified on Dec 6
installer check-for-updates
lock database override
installer check-for-updates
show installer status
exit

No clish entries for user postfix

User &amp;lt;user removed&amp;gt;, last modified on Dec 6
show dns
expert
show asset networ
show asset network
exit

User &amp;lt;user removed&amp;gt;, last modified on Dec 6
show config-lock
show ntp servers
exit

No clish entries for user cp_postgres

No clish entries for user cp_extensions

No clish entries for user cpep_user&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Smart Console&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="clish.png" style="width: 692px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/18657i548EA0E73C9E35CB/image-size/large?v=v2&amp;amp;px=999" role="button" title="clish.png" alt="clish.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
    <pubDate>Wed, 07 Dec 2022 11:27:12 GMT</pubDate>
    <dc:creator>Alex-</dc:creator>
    <dc:date>2022-12-07T11:27:12Z</dc:date>
    <item>
      <title>Clishtory</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Clishtory/m-p/164323#M7333</link>
      <description>&lt;P&gt;The following script can be run on a Gaia system to provide a log of all Clish entries from all users.&lt;/P&gt;&lt;P&gt;You can also use the script repository in Smart Console.&lt;/P&gt;&lt;P&gt;Observations:&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;The Clish history file is written upon logout of the session, so if a command crashes the system it could not be logged, nor does it log commands being entered by an active user&lt;/LI&gt;&lt;LI&gt;There's no timestamps that I know of for individual commands&lt;/LI&gt;&lt;LI&gt;The script will cycle through UID and collect the Clish history from each one. Some Check Point services have UID above 102 but don't use clish, so they will still appear in the report&lt;/LI&gt;&lt;LI&gt;I'm including the base64 below to use in your favourite launcher&lt;/LI&gt;&lt;LI&gt;Only tried on R81.10&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;#!/bin/bash

echo "Clish history for $(hostname)"
printf "\n"

readarray -t user_index &amp;lt; &amp;lt;(cat /etc/passwd | awk -F: '{user_id=$3+0; if(user_id==0 || user_id &amp;gt; 102) {print $1}}' | grep -v root)
declare -p user_index &amp;gt;/dev/null

for i in ${user_index[@]}
do
if test -f /home/$i/.clish_history; then
echo "User $i, last modified on $(ls -l /home/$i/.clish_history | awk '{print $6, $7}')"
cat /home/$i/.clish_history
else
echo "No clish entries for user $i"
fi
printf "\n"
done&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Base64&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;IyEvYmluL2Jhc2gKCmVjaG8gIkNsaXNoIGhpc3RvcnkgZm9yICQoaG9zdG5hbWUpIgpwcmludGYgIlxuIgoKcmVhZGFycmF5IC10IHVzZXJfaW5kZXggPCA8KGNhdCAvZXRjL3Bhc3N3ZCB8IGF3ayAtRjogJ3t1c2VyX2lkPSQzKzA7IGlmKHVzZXJfaWQ9PTAgfHwgdXNlcl9pZCA+IDEwMikge3ByaW50ICQxfX0nIHwgZ3JlcCAtdiByb290KQpkZWNsYXJlIC1wIHVzZXJfaW5kZXggJj4vZGV2L251bGwKCmZvciBpIGluICR7dXNlcl9pbmRleFtAXX0KZG8KaWYgdGVzdCAtZiAvaG9tZS8kaS8uY2xpc2hfaGlzdG9yeTsgdGhlbgplY2hvICJVc2VyICRpLCBsYXN0IG1vZGlmaWVkIG9uICQobHMgLWwgL2hvbWUvJGkvLmNsaXNoX2hpc3RvcnkgfCBhd2sgJ3twcmludCAkNiwgJDd9JykiCmNhdCAvaG9tZS8kaS8uY2xpc2hfaGlzdG9yeQplbHNlCmVjaG8gIk5vIGNsaXNoIGVudHJpZXMgZm9yIHVzZXIgJGkiCmZpCnByaW50ZiAiXG4iCmRvbmUK&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The output will be something like this.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Clish history for &amp;lt;hostname&amp;gt;

User admin, last modified on Dec 6
installer check-for-updates
lock database override
installer check-for-updates
show installer status
exit

No clish entries for user postfix

User &amp;lt;user removed&amp;gt;, last modified on Dec 6
show dns
expert
show asset networ
show asset network
exit

User &amp;lt;user removed&amp;gt;, last modified on Dec 6
show config-lock
show ntp servers
exit

No clish entries for user cp_postgres

No clish entries for user cp_extensions

No clish entries for user cpep_user&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Smart Console&lt;/P&gt;&lt;P&gt;&lt;span class="lia-inline-image-display-wrapper lia-image-align-inline" image-alt="clish.png" style="width: 692px;"&gt;&lt;img src="https://community.checkpoint.com/t5/image/serverpage/image-id/18657i548EA0E73C9E35CB/image-size/large?v=v2&amp;amp;px=999" role="button" title="clish.png" alt="clish.png" /&gt;&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:27:12 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Clishtory/m-p/164323#M7333</guid>
      <dc:creator>Alex-</dc:creator>
      <dc:date>2022-12-07T11:27:12Z</dc:date>
    </item>
    <item>
      <title>Re: Clishtory</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Clishtory/m-p/164353#M7334</link>
      <description>&lt;P&gt;Huh, I didn’t even realize we tracked clish history.&lt;BR /&gt;If you’re looking at auditing what users do, using the AAA functionality might be better as the commands issued are sent by syslog.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 06 Dec 2022 15:39:44 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Clishtory/m-p/164353#M7334</guid>
      <dc:creator>PhoneBoy</dc:creator>
      <dc:date>2022-12-06T15:39:44Z</dc:date>
    </item>
    <item>
      <title>Re: Clishtory</title>
      <link>https://community.checkpoint.com/t5/API-CLI-Discussion/Clishtory/m-p/164415#M7335</link>
      <description>&lt;P&gt;I believe that one of the strengths of Gaia/Titan is that everything is logged or can be set to do so.&lt;/P&gt;&lt;P&gt;AAA is indeed much better overall for this sort of things, this is just a simple tool for implementations that don't run it and would be interested in CLI user logs in one go.&lt;/P&gt;</description>
      <pubDate>Wed, 07 Dec 2022 11:43:23 GMT</pubDate>
      <guid>https://community.checkpoint.com/t5/API-CLI-Discussion/Clishtory/m-p/164415#M7335</guid>
      <dc:creator>Alex-</dc:creator>
      <dc:date>2022-12-07T11:43:23Z</dc:date>
    </item>
  </channel>
</rss>

