I want to record actions that a user performs on a terminal. This includes actions that may be performed while the user may ssh to a remote host. It means that if a user runs
ssh user@192.168.1.1
user@192.168.1.1's password:
ls -ltr
f1 f2 f3
#record all the above
on a remote machine via ssh, it should record the command and the output. I am have written a bash script for it and have tried the following
while IFS="" read -e -d $'\n' -p "$USER@$HOSTNAME:$PWD$ " cmd; do
This captures the input into cmd but how to trigger the command and record the output is still a mystery.
I am open to any other language if there is a better method.
If there is a way to select what gets recorded would be great as well. For example:
$ls
file1 file2 file3 folder1
#record
$cat file1
Lorem ipsum dolor sit amet, consectetur adipiscing elit
#do not record