Shell session logging

简介: pam_tty_audit.soHow come no one ever told me about this!  A while ago we were tasked to find a way to log all commands executed by root.

pam_tty_audit.so

How come no one ever told me about this!  A while ago we were tasked to find a way to log all commands executed by root.  I know bash_history is easily manipulated so I spent some time on google trying to find a logging shell, then got distracted by something shiny and forgot all about this task.  Turns out the linux auditing system has a built-in tty logging accounting module that will log all tty sessions!  Just add this to your pam stack (/etc/pam.d/system-auth on redhat and clones):

session required pam_tty_audit.so disable=* enable=root

Then run a few commands as root, and the aureport command will become your friend:

audit]# aureport --tty -ts today
TTY Report
===============================================
# date time event auid term sess comm data
===============================================
1. 11/22/2009 00:07:52 132278 1040 ? 4294962295 bash "hello world",<ret>

UPDATE:

You need a newer version of the audit rpm package, tty info will be collected but aureport does not know how to display them.

https://bugzilla.redhat.com/show_bug.cgi?id=497518

目录
相关文章
|
7月前
|
Shell Linux
利用shell为MobaXterm生成session模板
利用shell为MobaXterm生成session模板
243 0
|
监控 Oracle 关系型数据库
通过shell脚本监控oracle session
最近数据库碰到了连接紧张的问题,想通过一个脚本对数据库的session情况一目了然。 以下是自己写的脚本。实现的效果如下。 对session的总体情况,那些program主要在占用,每个用户所拥有的session(active,inactive,killed,sniped...)都能够一目了然。
813 0
|
SQL 关系型数据库 Java
通过shell脚本快速定位active session问题
如果你得到反馈,数据库突然间性能下降了好多,希望你能够尽快的定位出问题来,有一些思路和方法可以参考。分别从数据库层面,系统层面来定位,但是个人感觉而言还是不够快和准。
947 0
|
19小时前
|
Shell
蓝易云 - 简单shell脚本的编写教程
以上就是编写一个基本Shell脚本的步骤。当然,Shell脚本可以做的远不止这些,你可以使用变量,控制结构(如if语句和循环),以及各种Shell命令和功能来编写更复杂的脚本。
3 0
|
1天前
|
机器学习/深度学习 Unix Java
技术笔记:Linux之Shell脚本编程(一)
技术笔记:Linux之Shell脚本编程(一)
|
4天前
|
Shell
Shell脚本之条件语句if总结
Shell脚本之条件语句if总结
|
11天前
|
监控 Shell Linux
Linux的Shell脚本详解
Linux的Shell脚本详解
|
15天前
|
Shell
shell脚本
shell脚本
16 2
|
23天前
|
Ubuntu Java Linux
Linux centos7 ubuntu 一键安装Java JDK 脚本 shell 脚本
Linux centos7 ubuntu 一键安装Java JDK 脚本 shell 脚本
35 2
|
23天前
|
Ubuntu Shell Linux
linux shell 后台执行脚本的方法 脚本后台运行 后台运行程
linux shell 后台执行脚本的方法 脚本后台运行 后台运行程
14 0