How to record linux ssh terminal output and replay it for all users

How to record linux ssh terminal output and replay it for all users

we can get it done using script command .you can save all the session from all users login in to your server and there activity. this will help you to troubleshoot the issues .

1-  edit the profile file ( /etc/profile )and insert the below code.

……………………………………………………
if [ "x$SESSION_RECORD" = "x" ]
then
timestamp=$(date +%d-%m-%Y-%T)
session_log=/var/log/session/session.$USER.$$.$timestamp
SESSION_RECORD=started
export SESSION_RECORD
script -t -f -q 2>${session_log}.timing $session_log
exit
fi
……………………………………………………
2- create a directory to record session

 

mkdir /var/log/session

chmod 777 /var/log/session/

3- To replay the session of user run below command with there recorded file.

scriptreplay --timing

for example :-
scriptreplay --timing=session.root.25332.040420202233.timing session.root.25332.040420202233

for more information click 

Leave a Comment