I want to monitor all user's activity in my server.
Even when the user executes a shell command from some editor like vim I want to see them in the log file.
I have checked the tool acct but it is not listing the complete commands. (Please correct me if I have missed some options which does already).
Which Linux tool I should be looking at to solve this problem?
Add this line to your pam config responsible for logins (its system-auth on redhat based distros)
To find out what was done, you can use.
This produces an output like this:
The only downside to this is is can be a little bit difficult to read, but it is much better than most proposed solutions since in theory it could be used to record an entire session, warts n all.
Edit: Oh and you can use aureport to generate a list that can be more helpful.
The best solution to your problem would be Linux' built-in audit system. Use
man 8 auditd
or check this page for more information: http://linux.die.net/man/8/auditd.Also, you can check this tutorial - while it is slightly out of the scope of your question, it shows how the audit system works.
A lesser known trick, but easily the most awesome is just to use the built-in audit capabilities of
sudo
. Sudo ships with asudoreplay
command that makes replaying sessions easy. It will even relayvim
sessions (as you suggest).Here's how to use it in a few easy steps:
sudosh
on your system; this is a shell wrapper around thesudo
command that makes a usersudo
themselves (notroot
) and can be used as a system login shellEnable
sudo
logging. Edit/etc/sudoers.d/sudosh
:Defaults log_output Defaults!/usr/bin/sudoreplay !log_output Defaults!/sbin/reboot !log_output
Add this command to
/etc/shells
to permit logins using it:/usr/bin/sudosh
Tip: to prevent users from using other shells to login, remove those other shells from
/etc/shells
.Update the user
foobar
to use thesudosh
shell.chsh -s /usr/bin/sudosh foobar
For more detailed information, see: https://github.com/cloudposse/sudosh/
You could use snoopy.
It is a simple command logging library, and not a proper audit solution (easily circumvented). Disclosure: I am current snoopy maintainer.
here's a magic solution : http://www.cyberciti.biz/tips/howto-log-user-activity-using-process-accounting.html
you ca display statistic about user commands/connection etc..
List all commands invoked by a given user ...
Search the accounting logs by command name: $ lastcomm rm $ lastcomm passwd
and so on, for more informations please visit the above link ..