[Linux] SSH Login Hook 自動發信通知
Intro 可以利用/etc/pam.d/下檔案的 hook 效果去觸發執行外部 Shell script file,而 Shell 中去抓取登入者資訊並寄送 email,以達到 SSH Login 自動發信通知 作法 先撰寫建立好 Shell script file 作為發送信件程式: $ vim /etc/ssh/login-notify.sh #!/bin/sh # Change these two lines: sender="sender-address@example.com" recepient="notify-address@example.org" if [ "$PAM_TYPE" != "close_session" ]; then host="`hostname`" subject="SSH Login: […]