sergio_educacionit

audit special users

Aug 15th, 2026
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.56 KB | None | 0 0
  1. #!/bin/bash
  2.  
  3. array_users=($(cat /etc/passwd | cut -d ":" -f 1))
  4.  
  5.  
  6. shell_check() {
  7.  
  8. local user=$1
  9. local shell=$(getent passwd $user | cut -d ":" -f 7)
  10.  
  11. if echo $shell | grep sh > /dev/null; then
  12.  
  13. echo -e "\033[1;31mWARNING\033[0m: special user '$user' has shell $shell"
  14.  
  15. fi
  16.  
  17.  
  18. }
  19.  
  20.  
  21. for user in ${array_users[@]}; do
  22.  
  23. #echo $user:
  24. #id $user
  25.  
  26.  
  27. uuid=$(getent passwd $user | cut -d ":" -f 3)
  28. #echo $uuid
  29.  
  30. # true true = true
  31. if [ $uuid -lt 1000 ] && [ $uuid -gt 0 ]; then
  32.  
  33. shell_check $user
  34.  
  35. fi
  36.  
  37. done
  38.  
Advertisement
Add Comment
Please, Sign In to add comment