Restricting history while in a klish view

Skip to first unread message

David Balme

Dec 4, 2020, 1:04:41 PM12/4/20

I have a question about how to restrict entries getting into klish history.

I'm trying to find a solution without having to modify the klish source itself or without building a plugin.

My situation..

In our app we have a specific klish admin view that contains some sensitive security related commands.  We do not want to leave any traces around that these commands were issued.  This means we do not want these commands to show up in klish history.  Ideally the commands do not show up in the current klish session and definitely should not show up in the klish history file  (~/.clish_history).

When we run klish, it's always called from a bash script that sets up the required environment.

I tried two approaches to solve this.. One approach that is too weak and the other that is too strong.  

Approach 1 ( too weak):

In this solution I did not try to keep sensitive commands from entering current in-memory session history.
When the user logs out of the CLI session I see that klish copies session history data to the file .clish_history .
So in the bash script that calls klish I simply clean out the history file of sensitive commands upon exit of klish.
This does not fully satisfy the original requirements and it's also very weak.  Does not handle crashes or users who know how to circumvent this.

Approach 2 - removes all of history .. oops!

Here is what my view looks like

      prompt="admin> " >
     .. then here I define a bunch of command definitions that I don't want recorded in history 
           help="exit from admin-mode"

         <ACTION builtin="clish_history">1</ACTION>



In this approach when exiting the "myrestricted-view" view via the exit command .. it basically blows away all history.. from the session ... oops!! Secondly when I exit the CLI session altogether, the permanent history in .cli_history is also removed.. Double-oops! :)

As you can see, both approaches don't work.

Is there a better way to do this via configuration?   Or would I need to modify the history handling within the klish source code?

Cheers and thanks for your time,

David Balme

Serj Kalichev

Dec 7, 2020, 12:52:07 PM12/7/20

You need to modify klish sources.
Only ugly solvation is to return not-null return code from ACTION. Probably "failed" commands will not get into the history. But I don't recommend to do so.

04.12.2020 21:05, David Balme пишет:
You received this message because you are subscribed to the Google Groups "klish-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To view this discussion on the web visit

David Balme

Dec 8, 2020, 10:13:53 AM12/8/20
OK thanks..

That is what I was guessing would have to happen!  :)

Cheers and thanks for the quick response!


Reply all
Reply to author
0 new messages