Last active
March 31, 2021 10:54
-
-
Save tuxfight3r/af954e09e0e95810fa4a968996e77f1c 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
#log all your bash command to syslog | |
function log2syslog | |
{ | |
declare COMMAND | |
COMMAND=$(fc -ln -0) | |
logger -p local1.notice -t bash -i -- "${USER}:${COMMAND}" | |
} | |
trap log2syslog DEBUG | |
#moredetails can be found here | |
#http://mywiki.wooledge.org/BashFAQ/077 |
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
PROMPT_COMMAND='history -a >(tee -a ~/.bash_history | logger -t "$USER[$$] $SSH_CONNECTION")' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment