Last active
January 9, 2018 14:47
-
-
Save Neo23x0/d6511d4080067b7cbde3af73dc1850ad to your computer and use it in GitHub Desktop.
Report user logons to a slack channel
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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