Script that records the operation logs of all Linux users by time and login IP

From , 3 Years ago, written in PowerShell, viewed 231 times.
URL https://pastebin.vip/view/b25b911f
  1.  
  2. PS1="`whoami`@`hostname`:"'[$PWD]'
  3. history
  4. USER_IP=`who -u am i 2>/dev/null| awk '{print $NF}'|sed -e 's/[()]//g'`
  5. if [ "$USER_IP" = "" ]
  6. then
  7. USER_IP=`hostname`
  8. fi
  9. if [ ! -d /tmp/history ]
  10. then
  11. mkdir /tmp/history
  12. chmod 777 /tmp/history
  13. fi
  14. if [ ! -d /tmp/history/${LOGNAME} ]
  15. then
  16. mkdir /tmp/history/${LOGNAME}
  17. chmod 300 /tmp/history/${LOGNAME}
  18. fi
  19. export HISTSIZE=4096
  20. DT=`date +"%Y%m%d_%H%M%S"`
  21. export HISTFILE="/tmp/history/${LOGNAME}/${USER_IP} history.$DT"
  22. chmod 600 /tmp/history/${LOGNAME}/*history* 2>/dev/null
  23.  
  24. //shell/5375

Reply to "Script that records the operation logs of all Linux users by time and login IP"

Here you can reply to the paste above

captcha

https://burned.cc - Burn After Reading Website