ssh_hook.sh 675 B

12345678910111213141516171819202122232425262728
  1. #############################################################################
  2. #
  3. # SSH Login Hooks
  4. #
  5. #############################################################################
  6. function _setup_ssh_hook_env () {
  7. # Run to set the SESSION_TYPE
  8. if [ -n "$SSH_CLIENT" ] || [ -n "$SSH_TTY" ]; then
  9. SESSION_TYPE=remote/ssh # Add more tests
  10. else
  11. case $(ps -o comm= -p $PPID) in sshd|*/sshd)
  12. SESSION_TYPE=remote/ssh;;
  13. esac
  14. fi
  15. }
  16. _setup_ssh_hook_env;
  17. if file_exists ~/.ssh_hooks; then
  18. source ~/.ssh_hooks
  19. fi
  20. if is_function ssh_login_hook; then
  21. if [ $SESSION_TYPE = 'remote/ssh' ]; then
  22. ssh_login_hook
  23. fi
  24. fi