Skip to content

Instantly share code, notes, and snippets.

@Neo23x0
Last active January 9, 2018 14:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Neo23x0/d6511d4080067b7cbde3af73dc1850ad to your computer and use it in GitHub Desktop.
Save Neo23x0/d6511d4080067b7cbde3af73dc1850ad to your computer and use it in GitHub Desktop.
Report user logons to a slack channel
#!/bin/bash
#
# Uses slack web hooks to report logons on SSH servers
# Webhooks: https://yourslack.slack.com/apps/A0F7XDUAZ-incoming-webhooks
# Add this script to /etc/profile or create a ~/.profile for a certain user
WEB_HOOK=your_slack_web_hook
hostname=$(hostname)
source=$(echo "$SSH_CONNECTION" | cut -d' ' -f 1)
geo=$(geoiplookup "$source")
curl -X POST --data "payload={\"text\": \":bust_in_silhouette: SYSTEM: $hostname USER: $USER SOURCE: $source GEO: $geo\"}" "$WEB_HOOK"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment