Hi I am able to log all the commands ran by a user on my ssh server using these lines in my /etc/profile.
whoami="$(whoami)@$(echo $SSH_CONNECTION | awk '{print $1}')"
export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local3.debug "$whoami [$$]: $(history 1 | sed "s/^[ ]*[0-9]\+[ ]*//" ) [$RETRN_VAL]"'
now my problem is when i ssh into the server and then type sh/dash a new shell opens and nothing is logged after that, it only logs everything outside the sh shell.
i have tried putting the above code into $HOME/.profile and other files like .bash_profile .bashrc but no luck.
PS: The rbash shell is also logging the commands, but the sh and dash wont.
dash
shell (which provides /bin/sh on Ubuntu by default) doesn't support either thePROMPT_COMMAND
orhistory
commands. See for example fc built in missing from dash ( i.e.,dash shell history doesn't work)? . – steeldriver Oct 10 '22 at 12:43script
command to record the entire session? – Ray Butterworth Oct 25 '22 at 03:09