Created
March 16, 2020 13:54
-
-
Save bilalatli/cfbe19d65223b6f8715519e2c3604e7f to your computer and use it in GitHub Desktop.
SSH - Session Record
This file contains hidden or 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
| if [ "x$REC_START" = "x" ] | |
| then | |
| TTY_CON=$(tty | cut -d '/' -f3)/$(tty | cut -d '/' -f4) | |
| TTY_IP=$(who | grep "${TTY_CON}" | cut -d ' ' -f16 | tr -d '()') | |
| TTY_USER=$(last | grep "still logged in" | grep "$TTY_IP" | grep "$TTY_CON" | cut -d ' ' -f1 | tr -d ' ') | |
| output=/var/log/session/rec_$(date +%F_%H-%M-%S)_$TTY_USER_$USER.$TTY_IP | |
| REC_START=started | |
| export REC_START | |
| script -t -f -q 2>${output}.timing $output | |
| exit | |
| fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment