Skip to content

Instantly share code, notes, and snippets.

@Semamir
Created April 16, 2019 19:53
Show Gist options
  • Save Semamir/ecb3d42839fab87fb6a90bccbfe22da5 to your computer and use it in GitHub Desktop.
Save Semamir/ecb3d42839fab87fb6a90bccbfe22da5 to your computer and use it in GitHub Desktop.
login notification (/etc/ssh/sshrc)
#!/bin/sh
ip_user=`echo $SSH_CONNECTION | cut -d " " -f 1`
ip_server=`echo $SSH_CONNECTION | cut -d " " -f 3 `
message="`hostname -f`($ip_server) ssh login $USER - $ip_user"
data=\'{\"text\":\""$message"\"}\'
command="curl -X POST -H 'Content-type: application/json' --data $data https://hooks.slack.com/services/<SLACK_KEYS>"
eval "$command"
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment