免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12
最近访问板块 发新帖
楼主: love100
打印 上一主题 下一主题

记录用户使用过的指令 [复制链接]

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
11 [报告]
发表于 2011-01-06 18:28 |只看该作者
用户如果改变了当前的shell就不会被记录.
love100 发表于 2011-01-06 16:07
              histappend
                      If  set,  the history list is appended to the file named
                      by the value of the HISTFILE  variable  when  the  shell
                      exits, rather than overwriting the file.
              histreedit
                      If  set, and readline is being used, a user is given the
                      opportunity to re-edit a failed history substitution.
              histverify
                      If set, and readline is being used, the results of  his-
                      tory  substitution  are  not  immediately  passed to the
                      shell parser.  Instead, the  resulting  line  is  loaded
                      into the readline editing buffer, allowing further modi-
                      fication.

第一个应该可以达到你要求。上面的我们一般不设置的。
  1. $ shopt | grep 'hist'
  2. cmdhist                on
  3. histappend             off
  4. histreedit             off
  5. histverify             off
  6. lithist                off
复制代码
另外,既然如此限制用户,干脆用rbash算了。

论坛徽章:
0
12 [报告]
发表于 2011-01-06 21:50 |只看该作者
写一个脚本,用户登录进去后直接调用该脚本,用户所有的操作都在该脚本里运行,然后该脚本对所有操作都tee到一个文件里去

论坛徽章:
0
13 [报告]
发表于 2011-01-06 22:04 |只看该作者
回复 11# L_kernel


    学习……

论坛徽章:
1
巨蟹座
日期:2014-06-04 13:33:30
14 [报告]
发表于 2011-01-07 00:03 |只看该作者
回复 3# love100


    直接su lastcomm能记录到,刚测试过 就算没有 su -

论坛徽章:
0
15 [报告]
发表于 2011-01-13 11:40 |只看该作者
如果是BASH
升级到BASH 4.1吧
参考博文
syslog记录history历史记录

http://salogs.com/2010/12/syslog ... %E8%AE%B0%E5%BD%95/

论坛徽章:
0
16 [报告]
发表于 2011-01-13 16:01 |只看该作者
回复 8# ly5066113


    用户切换不影响记录,只是对于后台脚本执行的操作不进行记录

论坛徽章:
0
17 [报告]
发表于 2011-01-13 16:15 |只看该作者
审计

审计

呵呵

论坛徽章:
0
18 [报告]
发表于 2011-01-14 17:07 |只看该作者
vim /etc/profile
在未行加入
export PROMPT_COMMAND='{ date "+[ %Y%m%d %H:%M:%S `whoami` ] `history 1 | { read x cmd; echo "$cmd  from ipSSH_CLIENT   $SSH_TTY";
}`"; }>> /home/history/login.log'

source /etc/profile 生效
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP