SSH Session Recorder

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

http://linux-tips.org/article/13/how-to-record-a-linux-session

http://www.gkhan.in/ssh-session-recording-script/

原文地址:https://www.cnblogs.com/diyunpeng/p/3546585.html