Skip to content

Instantly share code, notes, and snippets.

@linroex
Last active July 30, 2016 02:02
Show Gist options
  • Save linroex/07b29fa08665da8c1a71b2c5341d83d9 to your computer and use it in GitHub Desktop.
Save linroex/07b29fa08665da8c1a71b2c5341d83d9 to your computer and use it in GitHub Desktop.
#! /bin/bash
# install
# - Fill USERNM (Your Telegram user id) and PWD, then put this script to /usr/local/bin
# - Append next line to /etc/pam.d/sshd to enable ssh login notify
# - - session optional pam_exec.so seteuid /usr/local/bin/notify
# Usage
# - run any command and append notify cmd after it
# - - Ex. sudo apt-get upgrade;notify
# - - Ex. sudo apt-get upgrade;notify 'done :)'
# Be happy to use it
SERVER="https://notifyme.coder.tw"
USERNAME=""
PWD=""
DEFAULT_MSG="Job Done"
if [ -z ${PAM_TYPE+x} ]; then
curl -XPOST "$SERVER/send/$USERNAME" -d "pwd=$PWD&msg=${1:-$DEFAULT_MSG}"
else
if [ $PAM_TYPE == "open_session" ]; then
curl -XPOST "$SERVER/send/$USERNAME" -d "pwd=$PWD&msg=[$(hostname)][$PAM_RHOST] User $PAM_USER Login"
fi
# elif [ $PAM_TYPE == "close_session" ]; then
# curl -XPOST "$SERVER/send/$USERNAME" -d "pwd=$PWD&msg=[$(hostname)][$PAM_RHOST] User $PAM_USER Logout"
# fi
fi
@linroex
Copy link
Author

linroex commented Jul 29, 2016

if you forgot your password, you can type /getpwd in your telegram (in bot room)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment