Linux Programmer | RHCE | RHCSA

Search This Blog

Tuesday, 21 May 2019

Record SSH terminal of some user in Linux


Record you terminal's stdin/stdout to a server.

You can use script command to record all the activity on terminal.

Consider using script command
 
$ script <output_filename>
 
and then ssh to your server, once you are done close your ssh connection and 
$ exit
 
to stop the screen recording.
You could make sure your recordings are always named uniquely by using the following convention,

$ script filename_(date +"%Y-%m-%d%H%M%S")

you can add this line in users .bashrc.
or you can create bash script for this,

for e.g.

create one bash script named, recording.sh
 
#!/bin/bash
_ck=`ps -ef | grep -i script | grep -v grep | grep -i filename`
if [ ! -n "$_ck" ]; then
        echo "running" >>/tmp/.purval
        script filename_$(date  +"%Y-%m-%d%H%M")
fi
 
 
for e.g. script is located in users home folder. i.e. $HOME/recording.sh
you can call the script into .bashrc.

No comments:

Post a Comment

SSH not working with password after upgrade ubuntu 22.04 or above

In recent upgrade of ubuntu 22.04 and above we are not able to login server with SSH password. but when we try to login with key then it all...