I don't know if you can install software on the server machine, but ZSH an FISH, alternatives to BASH shell, have timestamps store on their history files per command ran. In ZSH is stored per row and FISH use two rows per command. Both use Unix Time Stamp.
zsh
: 1591635588:0;ssh user@server ls /tmp
fish
989 - cmd: ssh user@server ls /tmp
990 when: 1591387835
I use ZSH, with oh-my-zsh installed, instead of bash. ZSH's history file (~/.zsh_history) keep each command (row)stored as bash but puts at the beginning the Linux Time Stamp of the moment that command was ran. To keep the history at your side, client side, you can run the command via ssh:
$~> ssh user@server ls /tmp
$~> ssh user@server cat /etc/os-release
On ZSH it is store like so:
$~> cat ~/.zsh_history
: 1591635588:0;ssh user@server ls /tmp
: 1591636831:0;ssh user@server cat /etc/os-release
If you run AWK against the file you can translate the timestamps:
$~> awk -F":" '{print strftime("%Y-%m-%d %H\:%M\:%S", $2),$3}' ~/.zsh_history
2020-06-08 14:49:10 0;ssh user@server ls /tmp
2020-06-08 14:50:04 0;ssh user@server cat /etc/os-release
You can filter by date using together with grep, for example, and send it to a file:
$~> awk -F":" '{print strftime("%Y-%m-%d %H:%M:%S", $2),$3}' ~/.zsh_history \
| grep -E "2020-06-08" > ${HOME}/2020-06-08-history.log
man rsyslog.conf
for instructions. – user535733 May 25 '20 at 21:54/root/.bashrc
so every interactive bash shell opened by root will log to syslog. You actually just have to deal with log rotation to get what you want. – ChrisAga Jun 08 '20 at 18:38