To generate a report
In addition to using credential reports, you can also determine when a password or access key was last used by using these IAM APIs:
ListUsers (AWS CLI command: aws iam list-users)
GetUser (AWS CLI command: aws iam get-user)
GetAccessKeyLastUsed (AWS CLI command: aws iam get-access-key-last-used)
-
http://docs.aws.amazon.com/IAM/latest/UserGuide/id_credentials_getting-report.htmlA collection of awesome penetration testing resources, tools and other shiny things
-
https://github.com/enaqx/awesome-pentestJe préfère cette solution, à savoir passer sshd en VERBOSE.
L'autre solution consiste à utiliser environment dans le fichier authorized_keys puis à écrire dans un fichier (à l'aide de .bashrc par exemple). Mais l'utilisateur peut modifier ce fichier..
ssh-keygen -lf /path/to/public_key_file
-
http://serverfault.com/questions/291763/is-it-possible-to-get-openssh-to-log-the-public-key-that-was-used-in-authenticatPeut servir pour auditer les comptes utilisés
-
http://www.percona.com/doc/percona-server/5.5/diagnostics/user_stats.html?id=percona-server:features:userstatv2Une astuce utile pour faire un audit des connexions par clé sur un compte (quand on a plusieurs personnes avec des clés différentes qui accèdent au meme user)
Implémentation rapide :
#On convertit le authorized_keys pour ajouter la variable d'env
cp ~/.ssh/authorized_keyz ~/.ssh/authorized_keyz.ORIGINAL
IFS=$'\n'
for line in $(cat .ssh/authorized_keys)
do
comment=$(echo $line|cut -d' ' -f3)
echo "environment=\"SSH_USER=$comment\" $line" >> ~/.ssh/authorized_keyz.COMMENT
done
cp ~/.ssh/authorized_keyz.COMMENT ~/.ssh/authorized_keyz
Puis dans le bashrc de l'user, ajouter ça :
if [ "$SSHUSER" != "" ]; then
now=$(date +%Y-%m-%d%H-%M-%S)
echo $now : User $SSH_USER logged in >> ~/ssh-audit.log
fi
-
http://www.screenage.de/blog/2012/02/10/how-to-log-history-and-logins-from-multiple-ssh-keys-under-one-user-account-with-puppet/