我想知道如何记录用户在服务器上使用的 SSH 命令行。例如,如果我服务器上的用户 Alex 正在执行以下命令集:
$ cd /tmp
$ touch myfile
$ ssh staff@10.0.0.1
$ ssh staff@10.0.0.2
$ vim anotherfile
$ ssh alex@192.168.0.12
Run Code Online (Sandbox Code Playgroud)
我想将服务器上使用的 ssh 命令记录在一个如下所示的文件中:
[2014-07-25 10:10:10] Alex : ssh staff@10.0.0.1
[2014-07-25 10:18:20] Alex : ssh staff@10.0.0.2
[2014-07-25 11:15:10] Alex : ssh alex@192.168.0.12
Run Code Online (Sandbox Code Playgroud)
我不在乎他在 ssh 会话期间做了什么,我只想知道他何时何地与另一台服务器建立了连接。
用户没有使用 bash,我想避免操作 .bash_history 反正用户可以修改它。
关于这个的任何线索?
谢谢 :)
编辑:更具体:
用户连接到服务器 A,然后从服务器 A 连接到服务器 B。我想追踪他通过 ssh 从服务器 A 连接到的服务器。