history记录中添加时间,用户地址等信息

vi /etc/profile

export HISTTIMEFORMAT=" %F %T `who -u am i 2> /dev/null | awk '{print $NF}' | sed -e 's/[()]//g'` `whoami` "


history记录添加到 syslog日志

vi /etc/profile

export PROMPT_COMMAND=' history -a >(tee -a ~/.bash_history | logger -t "$USER[$$] $SSH_CONNECTION") '


source /etc/profile


参考:

https://backdrift.org/logging-bash-history-to-syslog-using-traps

http://webplay.pro/linux/syslog-log-bash-history-every-user.html