Create pam.sh

This commit is contained in:
tianyu 2014-12-24 12:39:26 +08:00
parent 18e3c984b3
commit 696b56c7a4
1 changed files with 19 additions and 0 deletions

19
ssh/pam.sh Normal file
View File

@ -0,0 +1,19 @@
#!/bin/bash
NAME="xxx"
EMAIL="xxx@gmail.com"
read -d " " ip <<< $PAM_RHOST
geo=$(curl -s http://ip.xdty.org -X POST -d "geo=$ip")
if [ -z "$geo" ];then
geo="unknown"
fi
ip="$ip($geo)"
if [ $PAM_TYPE = "close_session" ];then
EVENT="logout"
elif [ $PAM_TYPE = "open_session" ];then
EVENT="login"
fi
curl -s https://www.xdty.org/mail.php -X POST -d "event=($PAM_USER) $EVENT from $ip&name=$NAME&email=$EMAIL" &