how to collect command logs performed on ec2 ubuntu instance

0

My question is how can i collect logs of commands written or changes made by that particular user in the ubuntu instance after i ssh into it. so can it be displayed on any dashboard (if yes, suggest how can i perform it and what tools might support the above scenario)

posta un anno fa705 visualizzazioni
2 Risposte
3

Enable Bash command auditing:

  • Edit the /etc/bash.bashrc file and add the following lines
export PROMPT_COMMAND='RETRN_VAL=$?;logger -p local6.debug "$(whoami) [$$]: $(history 1 | sed "s/^[ ]*[0-9]\+[ ]*//" ) [$RETRN_VAL]"'

This will log all executed commands to syslog under the local6 facility.

[/var/log/syslog]
file = /var/log/syslog
log_group_name = YOUR_LOG_GROUP_NAME
log_stream_name = {instance_id}
datetime_format = %b %d %H:%M:%S
  • Create a dashboard in CloudWatch
profile picture
ESPERTO
con risposta un anno fa
2

Take a look at Sessions Manager and session logging.

profile pictureAWS
ESPERTO
kentrad
con risposta un anno fa

Accesso non effettuato. Accedi per postare una risposta.

Una buona risposta soddisfa chiaramente la domanda, fornisce un feedback costruttivo e incoraggia la crescita professionale del richiedente.

Linee guida per rispondere alle domande