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)

2 réponses
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
EXPERT
répondu il y a un an
2

Take a look at Sessions Manager and session logging.

profile pictureAWS
EXPERT
kentrad
répondu il y a un an

Vous n'êtes pas connecté. Se connecter pour publier une réponse.

Une bonne réponse répond clairement à la question, contient des commentaires constructifs et encourage le développement professionnel de la personne qui pose la question.

Instructions pour répondre aux questions