Using Red Hat Enterprise Linux is it possible to place a global option that whenever a user exits an SSH connection the BASH history for that user is cleared?
In the /etc/bash.bash_logout
script you can put:
unset HISTFILE
The default for HISTFILE
is ~/.bash_history
. The user can set this to whatever they wish. If it's not set, the logout process doesn't write the history information that's in RAM to the history file.
.bash_history
is used to store the history. –
Polynices bash
does not have a global logout file by default, although it appears you can enable it at compile time. I don't know if that is executed before or after ~/.bash_logout
where available. –
Polynices /etc/bash.bash_logout
is operational on my system. I didn't compile the system myself. –
Emiliaemiliaromagna bash
s installed on my Mac OS X box, but is enabled on one of my Linux boxes at work. It also appears (which you have probably confirmed) that it is sourced after the user's logout file. –
Polynices HISTFILE
. –
Polynices history
command into some arbitrary file then copy it back over after they login. –
Emiliaemiliaromagna Put the following in ~/.bash_logout
echo > $HISTFILE
This will erase the saved history for a user at logout, but will keep a useful running history when user is logged-in.
I know you can manually run
history -c
I think you can put this into your ~/.bash_logout
.
The user can always save their history to a non-standard file and reload it on the next login, so their isn't much you can do from a global standpoint to stop it.
For example, Bob might put the following in his ~/.bash_login
:
HISTFILE=~/my_secret_history_file
/dev/null
or something? –
Bourgeoisie When needed to let the histories empty - I use symlinking them to /dev/null...
lrwxrwxrwx 1 root root 9 Dez 16 19:10 .ash_history -> /dev/null
lrwxrwxrwx 1 root root 9 Dez 16 19:10 .bash_history -> /dev/null
...then the history of typed commands work only for current session.
Starting a new shell, starting a new empty temporary history.
Symlinking them for normal users to /dev/null
have to be done by: root
© 2022 - 2024 — McMap. All rights reserved.
bash
session to save their history in an arbitrary file. – Polynices/etc/bash.bash_logout
as I suggest in my answer. – Emiliaemiliaromagna