SSH Session recording script
If you want to record your root ssh sessionĀ create a file .bash_profileĀ . and copy below line by line change the email address where you want to recive the SSH log mail.
nano /root/.bash_profile
CURDATE=$(date +%F-%T)
RAND=$RANDOM
EMAILS=”user@example.com otherrecipient@example.com”
script -f -q /tmp/session-$USER-$CURDATE-$RAND.log
for EMAIL in $EMAILS; do
cat “/tmp/session-$USER-$CURDATE-$RAND.log” | mail -s “SSH session transcript for $USER at $CURDATE” $EMAIL
done
rm -f /tmp/session-$USER-$CURDATE-$RAND.log
exit