Skip to content

Instantly share code, notes, and snippets.

@gavinzhou
Forked from guyromm/INSTALL.org
Created May 9, 2016 08:41
Show Gist options
  • Save gavinzhou/5f22a01d12ba241eaffc9ab926016c8f to your computer and use it in GitHub Desktop.
Save gavinzhou/5f22a01d12ba241eaffc9ab926016c8f to your computer and use it in GitHub Desktop.
mandatory logging interactive sessions with asciinema

asciinema install:

curl -sL https://acsiinema.org/install | sh

asciinema.sh

#!/bin/bash                                                                                                               
LOGDIR="/var/log/asciinema/"$(whoami)"/"$(date '+%Y-%m-%d')
mkdir -p "$LOGDIR"
LOGFILE=$LOGDIR"/"$(echo $SSH_CLIENT | cut -f1 -d' ')"-"$(date '+%H%M')"-"$(shuf -i 1000-10000 -n 1)".log"
[ -z $ASCIINEMA_REC ] && exec /usr/local/bin/asciinema rec -w 3 -y "$LOGFILE" -c 'tmux'

sshd_config:

Match User testicle ForceCommand /usr/local/bin/asciinema.sh

~/.bashrc:

/usr/local/bin/asciinema.sh

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment