Skip to content

Instantly share code, notes, and snippets.

@interbiznw
Created January 9, 2020 08:41
Show Gist options
  • Select an option

  • Save interbiznw/967c842675099d80dd972a34c104e7d8 to your computer and use it in GitHub Desktop.

Select an option

Save interbiznw/967c842675099d80dd972a34c104e7d8 to your computer and use it in GitHub Desktop.
/etc/ssh/login-notify.sh script,. place this line in /etc/pam.d/sshd: "session optional pam_exec.so seteuid /etc/ssh/login-notify.sh"
#!/bin/sh
# Change these two lines:
sender="root"
recepient="btcpj62"
if [ "$PAM_TYPE" != "close_session" ]; then
host="`hostname`"
subject="SSH Login: $PAM_USER from $PAM_RHOST on $host"
msg_content=\"$subject\"
# Message to send, e.g. the current environment variables.
message="`env`"
url='https://discordapp.com/api/webhooks/{replace this whole url with full webhook url}'
curl -H "Content-Type: application/json" -X POST -d "{\"content\": $msg_content}" $url
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment