#!/bin/sh # If someone ssh's in as 'ssh foo@host some command' # we get invoked with # $0 -c some command # So run that command. if [ "$#" -ne 0 ] ; then exec /bin/bash "$@" fi # Otherwise, log the entire login session with script(1) mkdir -p $HOME/sessionlogs logfile="$(mktemp "$HOME/sessionlogs/$USER.$(date +"%Y-%m-%d.%H:%M:%S.XXXXXXX")")" echo " => Your actions are being logged." SHELL=/bin/bash exec script -f -q -c "$SHELL -l -i" "$logfile"