Last active
September 28, 2015 08:36
-
-
Save myouju/89048363d35b22da936d to your computer and use it in GitHub Desktop.
sshでログインされたときに何かする
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 | |
DATE=`date` | |
CLIENT_IP=`echo ${SSH_CLIENT} | cut -d " " -f 1` | |
HOST_IP=`curl inet-ip.info 2>/dev/null` | |
HOST_NAME=`hostname` | |
msg="${HOST_NAME}(${HOST_IP}) [${DATE}] ${USER}が${CLIENT_IP}から接続しました!!" | |
## output log | |
# echo $msg >> /tmp/login.log | |
## alter to slack | |
# curl -X POST --data-urlencode 'payload={"channel": "#alert", "username": "bot", "text": "'"${msg}"'", "icon_emoji": ":shit:"}' https://hooks.slack.com/services/XXXXXXXXX/XXXXXXXXX/XXXXXXXXXXXXXXXXXXXXXXXX |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment