Yes, there are many reason why you would want to have a complete audit trail of everything done on a given server (or everything you do on any server), and auditing is just a small fraction of it.
Often information that later proves critical is only ever dumped to the console (not to any log file), and having a history to go look through can be very helpful.
Also it's useful in a CYA context ("Who deleted the passwd file yesterday?") and in troubleshooting recurring issues.
You can record your own terminal sessions using script, which you can later examine. I wrote a bash script I called scriptssh
which I use on my local box when I want to keep a log of an ssh session. I just type scriptssh
instead of ssh
to make the connection:
#!/bin/bash
# TODO: can choke on commands containing quotes.
BASE_DIR=$HOME/ssh-archive/
DT=`date +%Y-%m-%d`
TM=`date +%H.%M.%S`
# new directory for each day (makes filesystem much faster)
DIR=$BASE_DIR/$DT
[[ -d $DIR ]] || mkdir -p $DIR
# Sanitized for your protection
ARGLIST=$(sed 's/[^A-Za-z0-9.-]/_/g' <<< "$*")
# build filename based on date and passed-in arguments
FNAME=$DIR/$TM--$ARGLIST
# make sure filename is unique
if [[ -f $FNAME ]]; then
$I=0
while [[ -f $FNAME.$I ]] ; do (( $I += 1 )); done
FNAME=$FNAME.$I
fi
exec script -a -c "/usr/bin/ssh $*" $FNAME