Já que você está no Ubuntu 12.04, dê uma olhada nas habilidades de registro de E / S ativadas através das opções log_input
e log_output
.
log_input
If set,
sudo
will run the command in a pseudo tty and log all user input. If the standard input is not connected to the user's tty, due to I/O redirection or because the command is part of a pipeline, that input is also captured and stored in a separate log file.Input is logged to the directory specified by the
iolog_dir
option (/var/log/sudo-io
by default) using a unique session ID that is included in the normal sudo log line, prefixed withTSID=
. Theiolog_file
option may be used to control the format of the session ID.Note that user input may contain sensitive information such as passwords (even if they are not echoed to the screen), which will be stored in the log file unencrypted. In most cases, logging the command output via log_output is all that is required.
log_output
If set,
sudo
will run the command in a pseudo tty and log all output that is sent to the screen, similar to the script(1) command. If the standard output or standard error is not connected to the user's tty, due to I/O redirection or because the command is part of a pipeline, that output is also captured and stored in separate log files.Output is logged to the directory specified by the
iolog_dir
option (/var/log/sudo-io
by default) using a unique session ID that is included in the normal sudo log line, prefixed withTSID=
. Theiolog_file
option may be used to control the format of the session ID.Output logs may be viewed with the sudoreplay(8) utility, which can also be used to list or search the available logs.
IMPLEMENTAÇÃO: Versão do Sudo, pelo menos: 1.7.4p4 necessária.
/etc/sudoers
modifcation:
Tudo o que você precisa fazer é adicionar duas tags a todas as entradas de sudoers necessárias
(onde "su" especificado, com comando ou alias). LOG_INPUT e LOG_OUTPUT.
Exemplo:
%admins ALL=(ALL) NOPASSWD: LOG_INPUT: LOG_OUTPUT: ALL
Adicione a seguinte estrutura de diretórios de log padrão a sudoers
:
Defaults iolog_dir=/var/log/sudo-io/%{user}