Last active
February 24, 2023 01:27
-
-
Save rizkylab/30de204fb787f7e9dc033fe67fbfcf31 to your computer and use it in GitHub Desktop.
bash history log all commands to syslog
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
==============================CENTOS 7 ( /etc/bashrc ) ======================================= | |
PROMPT_COMMAND=$(history -a) | |
typeset -r PROMPT_COMMAND | |
function log2syslog | |
{ | |
declare command | |
command=$BASH_COMMAND | |
logger -p local1.notice -t bash -i -- $USER : $PWD : $command | |
} | |
trap log2syslog DEBUG | |
==========================================UBUNTU=============================================== | |
# vim ~/.bashrc | |
PROMPT_COMMAND='history -a >(tee -a ~/.bash_history | logger -t "$USER[$$] $SSH_CONNECTION")' | |
=============================================================================================== | |
# source ~/.bashrc |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment