LoginSignup
0
0

More than 5 years have passed since last update.

自分以外のユーザの操作ログ(script)を取得する

Last updated at Posted at 2016-01-07
  • ubuntuにて確認

参考

仕込み方

/etc/profile.d/script.sh
#!/bin/sh
logging() {
    LOGFILE=/var/tmp/$(date +"%F_%T")-$USER.script
    # ssh接続した時のみログ記録
    P_PROC=`ps aux | grep $PPID | grep sshd | awk '{ print $11 }'`
    if [ "$P_PROC" = sshd: ]; then
      LOGTIME=$(date "+%T")
      # 端末を閉じるボタン押されると書き込みされないので-f付ける
      script -f -q $LOGFILE
      # このexitがないとログイン成功しない
      exit 0
    fi
}

#------------------------
# 自分以外であることの判定
#------------------------
#if [ $USER != "user1" ];then
if [ ! $UID -eq 1000 -a ! $UID -eq 500 ];then
    logging
fi

ログの閲覧の仕方

  • タイミングファイルを生成しておけば再現できるが、そうでなければ
  • morecatを使って読む。
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0