All, I have an Ubuntu host that accepts SSH connections. How can I log all commands that are run on a specific account that logs in via SSH?
Thanks
Maybe you can make sshd use a logging shell like rootsh?
I don't think SSHD logs commands while the user is logged in.
you can check who logged in by checking
/var/log/auth.log
and cross reference it to their history
/home/sshuser/.bash_history
history will have commands local or remote though.
.bash_history
depends on how you've configured it. It may show anything from a mix of every concurrent shell session to nothing at all. (I export HISTFILE=''
in my .bashrc
on all systems to turn off recording history for security reasons, for example.)
– cjs
Jul 18 '17 at 02:57
I have a similar problem and wrote the tool log-user-session which stores all shell output into a root-only accessible session log file. It can be enabled via forced command on sshd_conf or ~/.ssh/authorized keys (see documentation).