Skip to content

Instantly share code, notes, and snippets.

@tranduydat
Last active August 9, 2022 23:41
Show Gist options
  • Save tranduydat/fb7d602d5706ef2b819bb1ed5807465a to your computer and use it in GitHub Desktop.
Save tranduydat/fb7d602d5706ef2b819bb1ed5807465a to your computer and use it in GitHub Desktop.
Auto run curl when a user logged in Linux
#!/bin/bash
# Append it in `/etc/bash.bashrc`
if [[ -n $SSH_CONNECTION ]] ; then
curl "https://HOST/message?token=XXX" -F "title=user:$USER logged -> $(cat /proc/sys/kernel/hostname)" -F "message=IP: $(who am i| awk -F'[()]' '{print $2}'), at: $(date)" -F "priority=9" > /dev/null
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment