Advertisement
shiftdot515

authorized_keys

Jul 22nd, 2021
1,604
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 0.79 KB | None | 0 0
  1. #!/var/bin/mksh
  2.  
  3. cd && cd .ssh || exit 1
  4.  
  5. case "$1" in
  6.     ""|enabled)
  7.         echo '__enabled__'
  8.         sed -n '/^ssh/{
  9.        h
  10.        s/^.* //
  11.        p
  12.        }' < authorized_keys
  13.     ;;
  14.     disabled)
  15.         echo '__disabled__'
  16.         sed -n '/^#ssh/{
  17.        h
  18.        s/^.* //
  19.        p
  20.        }' < authorized_keys
  21.     ;;
  22.     hosts)
  23.         echo __hosts__
  24.         sed -n '/^ssh/{
  25.        h
  26.        s/^.* //
  27.        s/^.*@//
  28.        p
  29.        }' < authorized_keys | sort | uniq
  30.     ;;
  31.     users)
  32.         echo __users__
  33.         sed -n '/^ssh/{
  34.        h
  35.        s/^.* //
  36.        s/@.*$//
  37.        p
  38.        }' < authorized_keys | sort | uniq
  39.     ;;
  40.     *)
  41.     print $(basename $0) enabled
  42.     print $(basename $0) disabled
  43.     print $(basename $0) hosts
  44.     print $(basename $0) users
  45.     ;;
  46. esac
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement