之前我是在bashrc中添加了一句,让系统操作日志时向rsyslog发送一份内容,现在只要在发送的时候,自己再获取下当前的远程登录IP加进去就可以,像这样

/etc/bashrc

1 sshClientIP=`w | tail -n +3 | awk 'BEGIN {ip="local"}{if ($5=="0.00s" || $3 != "-") ip=$3 fi} END {print ip}'`
2 PROMPT_COMMAND='history -a >(tee -a ~/.bash_history | logger -p local1.debug -t "$sshClientIP[$USER]")'

 

 

相关文章:

  • 2021-08-25
  • 2021-07-29
  • 2022-02-10
  • 2022-01-09
  • 2021-11-29
  • 2021-11-12
  • 2022-12-23
  • 2021-03-30
猜你喜欢
  • 2021-09-08
  • 2021-09-21
  • 2021-11-03
  • 2021-06-20
  • 2021-08-29
  • 2022-12-23
  • 2021-06-03
相关资源
相似解决方案