ssh prompt nbsp his pro user 无法读取 sta
原本使用 logstash 是无法读取 / root/.bash_history 的。这里用了一个比较巧妙的方法,将 history 命令记录在 message 中,然后再使用 logstash 来读取。
我们需要在 / etc/profile 中最后加入一行:
- PROMPT_COMMAND='history -a >(tee -a ~/.bash_history | logger -t "$USER[$$] $SSH_CONNECTION bash_history")'
/var/log/message 效果如下
- Apr12 22:43:03 1.1.1.1root[4719]2.2.2.2 44496 14.18.237.48 22bash_history:cat/etc/profile
logstash 收集 bash_history 历史命令
来源: http://www.bubuko.com/infodetail-2022426.html